msi: Expand REG_EXPAND_SZ registry values in the RegLocator table.
[wine] / dlls / msi / tests / package.c
1 /*
2  * tests for Microsoft Installer functionality
3  *
4  * Copyright 2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #define COBJMACROS
23
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29
30 #include "wine/test.h"
31
32 static const char msifile[] = "winetest.msi";
33 char CURR_DIR[MAX_PATH];
34
35 static void get_user_sid(LPSTR *usersid)
36 {
37     HANDLE token;
38     BYTE buf[1024];
39     DWORD size;
40     PTOKEN_USER user;
41     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
42     static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
43
44     *usersid = NULL;
45     pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
46     if (!pConvertSidToStringSidA)
47         return;
48
49     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
50     size = sizeof(buf);
51     GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
52     user = (PTOKEN_USER)buf;
53     pConvertSidToStringSidA(user->User.Sid, usersid);
54 }
55
56 /* RegDeleteTreeW from dlls/advapi32/registry.c */
57 LSTATUS WINAPI package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
58 {
59     LONG ret;
60     DWORD dwMaxSubkeyLen, dwMaxValueLen;
61     DWORD dwMaxLen, dwSize;
62     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
63     HKEY hSubKey = hKey;
64
65     if(lpszSubKey)
66     {
67         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
68         if (ret) return ret;
69     }
70
71     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
72             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
73     if (ret) goto cleanup;
74
75     dwMaxSubkeyLen++;
76     dwMaxValueLen++;
77     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
78     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
79     {
80         /* Name too big: alloc a buffer for it */
81         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
82         {
83             ret = ERROR_NOT_ENOUGH_MEMORY;
84             goto cleanup;
85         }
86     }
87
88     /* Recursively delete all the subkeys */
89     while (TRUE)
90     {
91         dwSize = dwMaxLen;
92         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
93                           NULL, NULL, NULL)) break;
94
95         ret = package_RegDeleteTreeW(hSubKey, lpszName);
96         if (ret) goto cleanup;
97     }
98
99     if (lpszSubKey)
100         ret = RegDeleteKeyW(hKey, lpszSubKey);
101     else
102         while (TRUE)
103         {
104             dwSize = dwMaxLen;
105             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
106                   NULL, NULL, NULL, NULL)) break;
107
108             ret = RegDeleteValueW(hKey, lpszName);
109             if (ret) goto cleanup;
110         }
111
112 cleanup:
113     if (lpszName != szNameBuf)
114         HeapFree(GetProcessHeap(), 0, lpszName);
115     if(lpszSubKey)
116         RegCloseKey(hSubKey);
117     return ret;
118 }
119
120 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
121 {
122     DWORD i,n=1;
123     GUID guid;
124
125     if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
126         return FALSE;
127
128     for(i=0; i<8; i++)
129         out[7-i] = in[n++];
130     n++;
131     for(i=0; i<4; i++)
132         out[11-i] = in[n++];
133     n++;
134     for(i=0; i<4; i++)
135         out[15-i] = in[n++];
136     n++;
137     for(i=0; i<2; i++)
138     {
139         out[17+i*2] = in[n++];
140         out[16+i*2] = in[n++];
141     }
142     n++;
143     for( ; i<8; i++)
144     {
145         out[17+i*2] = in[n++];
146         out[16+i*2] = in[n++];
147     }
148     out[32]=0;
149     return TRUE;
150 }
151
152 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
153                                LPCSTR guid, LPSTR usersid, BOOL dir)
154 {
155     WCHAR guidW[MAX_PATH];
156     WCHAR squashedW[MAX_PATH];
157     CHAR squashed[MAX_PATH];
158     CHAR comppath[MAX_PATH];
159     CHAR prodpath[MAX_PATH];
160     CHAR path[MAX_PATH];
161     LPCSTR prod = NULL;
162     HKEY hkey;
163
164     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
165     squash_guid(guidW, squashedW);
166     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
167
168     if (context == MSIINSTALLCONTEXT_MACHINE)
169     {
170         prod = "3D0DAE300FACA1300AD792060BCDAA92";
171         sprintf(comppath,
172                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
173                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
174         lstrcpyA(prodpath,
175                  "SOFTWARE\\Classes\\Installer\\"
176                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
177     }
178     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
179     {
180         prod = "7D2F387510109040002000060BECB6AB";
181         sprintf(comppath,
182                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
183                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
184         sprintf(prodpath,
185                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
186                 "Installer\\%s\\Installer\\Products\\"
187                 "7D2F387510109040002000060BECB6AB", usersid);
188     }
189     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
190     {
191         prod = "7D2F387510109040002000060BECB6AB";
192         sprintf(comppath,
193                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
194                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
195         sprintf(prodpath,
196                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
197                 "Installer\\Managed\\%s\\Installer\\Products\\"
198                 "7D2F387510109040002000060BECB6AB", usersid);
199     }
200
201     RegCreateKeyA(HKEY_LOCAL_MACHINE, comppath, &hkey);
202
203     lstrcpyA(path, CURR_DIR);
204     lstrcatA(path, "\\");
205     if (!dir) lstrcatA(path, filename);
206
207     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
208     RegCloseKey(hkey);
209
210     RegCreateKeyA(HKEY_LOCAL_MACHINE, prodpath, &hkey);
211     RegCloseKey(hkey);
212 }
213
214 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
215 {
216     WCHAR guidW[MAX_PATH];
217     WCHAR squashedW[MAX_PATH];
218     WCHAR substrW[MAX_PATH];
219     CHAR squashed[MAX_PATH];
220     CHAR comppath[MAX_PATH];
221     CHAR prodpath[MAX_PATH];
222
223     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
224     squash_guid(guidW, squashedW);
225     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
226
227     if (context == MSIINSTALLCONTEXT_MACHINE)
228     {
229         sprintf(comppath,
230                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
231                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
232         lstrcpyA(prodpath,
233                  "SOFTWARE\\Classes\\Installer\\"
234                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
235     }
236     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
237     {
238         sprintf(comppath,
239                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
240                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
241         sprintf(prodpath,
242                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
243                 "Installer\\%s\\Installer\\Products\\"
244                 "7D2F387510109040002000060BECB6AB", usersid);
245     }
246     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
247     {
248         sprintf(comppath,
249                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
250                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
251         sprintf(prodpath,
252                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
253                 "Installer\\Managed\\%s\\Installer\\Products\\"
254                 "7D2F387510109040002000060BECB6AB", usersid);
255     }
256
257     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
258     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
259
260     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
261     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
262 }
263
264 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
265 {
266     MSIHANDLE hview = 0;
267     UINT r, ret;
268
269     /* open a select query */
270     r = MsiDatabaseOpenView(hdb, query, &hview);
271     if (r != ERROR_SUCCESS)
272         return r;
273     r = MsiViewExecute(hview, 0);
274     if (r != ERROR_SUCCESS)
275         return r;
276     ret = MsiViewFetch(hview, phrec);
277     r = MsiViewClose(hview);
278     if (r != ERROR_SUCCESS)
279         return r;
280     r = MsiCloseHandle(hview);
281     if (r != ERROR_SUCCESS)
282         return r;
283     return ret;
284 }
285
286 static UINT run_query( MSIHANDLE hdb, const char *query )
287 {
288     MSIHANDLE hview = 0;
289     UINT r;
290
291     r = MsiDatabaseOpenView(hdb, query, &hview);
292     if( r != ERROR_SUCCESS )
293         return r;
294
295     r = MsiViewExecute(hview, 0);
296     if( r == ERROR_SUCCESS )
297         r = MsiViewClose(hview);
298     MsiCloseHandle(hview);
299     return r;
300 }
301
302 static UINT create_component_table( MSIHANDLE hdb )
303 {
304     return run_query( hdb,
305             "CREATE TABLE `Component` ( "
306             "`Component` CHAR(72) NOT NULL, "
307             "`ComponentId` CHAR(38), "
308             "`Directory_` CHAR(72) NOT NULL, "
309             "`Attributes` SHORT NOT NULL, "
310             "`Condition` CHAR(255), "
311             "`KeyPath` CHAR(72) "
312             "PRIMARY KEY `Component`)" );
313 }
314
315 static UINT create_feature_table( MSIHANDLE hdb )
316 {
317     return run_query( hdb,
318             "CREATE TABLE `Feature` ( "
319             "`Feature` CHAR(38) NOT NULL, "
320             "`Feature_Parent` CHAR(38), "
321             "`Title` CHAR(64), "
322             "`Description` CHAR(255), "
323             "`Display` SHORT NOT NULL, "
324             "`Level` SHORT NOT NULL, "
325             "`Directory_` CHAR(72), "
326             "`Attributes` SHORT NOT NULL "
327             "PRIMARY KEY `Feature`)" );
328 }
329
330 static UINT create_feature_components_table( MSIHANDLE hdb )
331 {
332     return run_query( hdb,
333             "CREATE TABLE `FeatureComponents` ( "
334             "`Feature_` CHAR(38) NOT NULL, "
335             "`Component_` CHAR(72) NOT NULL "
336             "PRIMARY KEY `Feature_`, `Component_` )" );
337 }
338
339 static UINT create_file_table( MSIHANDLE hdb )
340 {
341     return run_query( hdb,
342             "CREATE TABLE `File` ("
343             "`File` CHAR(72) NOT NULL, "
344             "`Component_` CHAR(72) NOT NULL, "
345             "`FileName` CHAR(255) NOT NULL, "
346             "`FileSize` LONG NOT NULL, "
347             "`Version` CHAR(72), "
348             "`Language` CHAR(20), "
349             "`Attributes` SHORT, "
350             "`Sequence` SHORT NOT NULL "
351             "PRIMARY KEY `File`)" );
352 }
353
354 static UINT create_remove_file_table( MSIHANDLE hdb )
355 {
356     return run_query( hdb,
357             "CREATE TABLE `RemoveFile` ("
358             "`FileKey` CHAR(72) NOT NULL, "
359             "`Component_` CHAR(72) NOT NULL, "
360             "`FileName` CHAR(255) LOCALIZABLE, "
361             "`DirProperty` CHAR(72) NOT NULL, "
362             "`InstallMode` SHORT NOT NULL "
363             "PRIMARY KEY `FileKey`)" );
364 }
365
366 static UINT create_appsearch_table( MSIHANDLE hdb )
367 {
368     return run_query( hdb,
369             "CREATE TABLE `AppSearch` ("
370             "`Property` CHAR(72) NOT NULL, "
371             "`Signature_` CHAR(72) NOT NULL "
372             "PRIMARY KEY `Property`, `Signature_`)" );
373 }
374
375 static UINT create_reglocator_table( MSIHANDLE hdb )
376 {
377     return run_query( hdb,
378             "CREATE TABLE `RegLocator` ("
379             "`Signature_` CHAR(72) NOT NULL, "
380             "`Root` SHORT NOT NULL, "
381             "`Key` CHAR(255) NOT NULL, "
382             "`Name` CHAR(255), "
383             "`Type` SHORT "
384             "PRIMARY KEY `Signature_`)" );
385 }
386
387 static UINT create_signature_table( MSIHANDLE hdb )
388 {
389     return run_query( hdb,
390             "CREATE TABLE `Signature` ("
391             "`Signature` CHAR(72) NOT NULL, "
392             "`FileName` CHAR(255) NOT NULL, "
393             "`MinVersion` CHAR(20), "
394             "`MaxVersion` CHAR(20), "
395             "`MinSize` LONG, "
396             "`MaxSize` LONG, "
397             "`MinDate` LONG, "
398             "`MaxDate` LONG, "
399             "`Languages` CHAR(255) "
400             "PRIMARY KEY `Signature`)" );
401 }
402
403 static UINT create_launchcondition_table( MSIHANDLE hdb )
404 {
405     return run_query( hdb,
406             "CREATE TABLE `LaunchCondition` ("
407             "`Condition` CHAR(255) NOT NULL, "
408             "`Description` CHAR(255) NOT NULL "
409             "PRIMARY KEY `Condition`)" );
410 }
411
412 static UINT create_property_table( MSIHANDLE hdb )
413 {
414     return run_query( hdb,
415             "CREATE TABLE `Property` ("
416             "`Property` CHAR(72) NOT NULL, "
417             "`Value` CHAR(0) "
418             "PRIMARY KEY `Property`)" );
419 }
420
421 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
422 {
423     return run_query( hdb,
424             "CREATE TABLE `InstallExecuteSequence` ("
425             "`Action` CHAR(72) NOT NULL, "
426             "`Condition` CHAR(255), "
427             "`Sequence` SHORT "
428             "PRIMARY KEY `Action`)" );
429 }
430
431 static UINT create_media_table( MSIHANDLE hdb )
432 {
433     return run_query( hdb,
434             "CREATE TABLE `Media` ("
435             "`DiskId` SHORT NOT NULL, "
436             "`LastSequence` SHORT NOT NULL, "
437             "`DiskPrompt` CHAR(64), "
438             "`Cabinet` CHAR(255), "
439             "`VolumeLabel` CHAR(32), "
440             "`Source` CHAR(72) "
441             "PRIMARY KEY `DiskId`)" );
442 }
443
444 static UINT create_ccpsearch_table( MSIHANDLE hdb )
445 {
446     return run_query( hdb,
447             "CREATE TABLE `CCPSearch` ("
448             "`Signature_` CHAR(72) NOT NULL "
449             "PRIMARY KEY `Signature_`)" );
450 }
451
452 static UINT create_drlocator_table( MSIHANDLE hdb )
453 {
454     return run_query( hdb,
455             "CREATE TABLE `DrLocator` ("
456             "`Signature_` CHAR(72) NOT NULL, "
457             "`Parent` CHAR(72), "
458             "`Path` CHAR(255), "
459             "`Depth` SHORT "
460             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
461 }
462
463 static UINT create_complocator_table( MSIHANDLE hdb )
464 {
465     return run_query( hdb,
466             "CREATE TABLE `CompLocator` ("
467             "`Signature_` CHAR(72) NOT NULL, "
468             "`ComponentId` CHAR(38) NOT NULL, "
469             "`Type` SHORT "
470             "PRIMARY KEY `Signature_`)" );
471 }
472
473 static UINT create_inilocator_table( MSIHANDLE hdb )
474 {
475     return run_query( hdb,
476             "CREATE TABLE `IniLocator` ("
477             "`Signature_` CHAR(72) NOT NULL, "
478             "`FileName` CHAR(255) NOT NULL, "
479             "`Section` CHAR(96)NOT NULL, "
480             "`Key` CHAR(128)NOT NULL, "
481             "`Field` SHORT, "
482             "`Type` SHORT "
483             "PRIMARY KEY `Signature_`)" );
484 }
485
486 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
487 {
488     char insert[] = "INSERT INTO `Component`  "
489             "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
490             "VALUES( %s )";
491     char *query;
492     UINT sz, r;
493
494     sz = strlen(values) + sizeof insert;
495     query = HeapAlloc(GetProcessHeap(),0,sz);
496     sprintf(query,insert,values);
497     r = run_query( hdb, query );
498     HeapFree(GetProcessHeap(), 0, query);
499     return r;
500 }
501
502 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
503 {
504     char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
505     char *query;
506     UINT sz, r;
507
508     sz = strlen(values) + sizeof insert;
509     query = HeapAlloc(GetProcessHeap(),0,sz);
510     sprintf(query,insert,values);
511     r = run_query( hdb, query );
512     HeapFree(GetProcessHeap(), 0, query);
513     return r;
514 }
515
516 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
517 {
518     char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
519                     "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
520     char *query;
521     UINT sz, r;
522
523     sz = strlen(values) + sizeof insert;
524     query = HeapAlloc(GetProcessHeap(),0,sz);
525     sprintf(query,insert,values);
526     r = run_query( hdb, query );
527     HeapFree(GetProcessHeap(), 0, query);
528     return r;
529 }
530
531 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
532 {
533     char insert[] = "INSERT INTO `FeatureComponents` "
534             "(`Feature_`, `Component_`) "
535             "VALUES( %s )";
536     char *query;
537     UINT sz, r;
538
539     sz = strlen(values) + sizeof insert;
540     query = HeapAlloc(GetProcessHeap(),0,sz);
541     sprintf(query,insert,values);
542     r = run_query( hdb, query );
543     HeapFree(GetProcessHeap(), 0, query);
544     return r;
545 }
546
547 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
548 {
549     char insert[] = "INSERT INTO `File` "
550             "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
551             "VALUES( %s )";
552     char *query;
553     UINT sz, r;
554
555     sz = strlen(values) + sizeof insert;
556     query = HeapAlloc(GetProcessHeap(),0,sz);
557     sprintf(query,insert,values);
558     r = run_query( hdb, query );
559     HeapFree(GetProcessHeap(), 0, query);
560     return r;
561 }
562
563 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
564 {
565     char insert[] = "INSERT INTO `AppSearch` "
566             "(`Property`, `Signature_`) "
567             "VALUES( %s )";
568     char *query;
569     UINT sz, r;
570
571     sz = strlen(values) + sizeof insert;
572     query = HeapAlloc(GetProcessHeap(),0,sz);
573     sprintf(query,insert,values);
574     r = run_query( hdb, query );
575     HeapFree(GetProcessHeap(), 0, query);
576     return r;
577 }
578
579 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
580 {
581     char insert[] = "INSERT INTO `RegLocator` "
582             "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
583             "VALUES( %s )";
584     char *query;
585     UINT sz, r;
586
587     sz = strlen(values) + sizeof insert;
588     query = HeapAlloc(GetProcessHeap(),0,sz);
589     sprintf(query,insert,values);
590     r = run_query( hdb, query );
591     HeapFree(GetProcessHeap(), 0, query);
592     return r;
593 }
594
595 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
596 {
597     char insert[] = "INSERT INTO `Signature` "
598             "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
599             " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
600             "VALUES( %s )";
601     char *query;
602     UINT sz, r;
603
604     sz = strlen(values) + sizeof insert;
605     query = HeapAlloc(GetProcessHeap(),0,sz);
606     sprintf(query,insert,values);
607     r = run_query( hdb, query );
608     HeapFree(GetProcessHeap(), 0, query);
609     return r;
610 }
611
612 static UINT add_launchcondition_entry( MSIHANDLE hdb, const char *values )
613 {
614     char insert[] = "INSERT INTO `LaunchCondition` "
615             "(`Condition`, `Description`) "
616             "VALUES( %s )";
617     char *query;
618     UINT sz, r;
619
620     sz = strlen(values) + sizeof insert;
621     query = HeapAlloc(GetProcessHeap(),0,sz);
622     sprintf(query,insert,values);
623     r = run_query( hdb, query );
624     HeapFree(GetProcessHeap(), 0, query);
625     return r;
626 }
627
628 static UINT add_property_entry( MSIHANDLE hdb, const char *values )
629 {
630     char insert[] = "INSERT INTO `Property` "
631             "(`Property`, `Value`) "
632             "VALUES( %s )";
633     char *query;
634     UINT sz, r;
635
636     sz = strlen(values) + sizeof insert;
637     query = HeapAlloc(GetProcessHeap(),0,sz);
638     sprintf(query,insert,values);
639     r = run_query( hdb, query );
640     HeapFree(GetProcessHeap(), 0, query);
641     return r;
642 }
643
644 static UINT add_install_execute_sequence_entry( MSIHANDLE hdb, const char *values )
645 {
646     char insert[] = "INSERT INTO `InstallExecuteSequence` "
647             "(`Action`, `Condition`, `Sequence`) "
648             "VALUES( %s )";
649     char *query;
650     UINT sz, r;
651
652     sz = strlen(values) + sizeof insert;
653     query = HeapAlloc(GetProcessHeap(),0,sz);
654     sprintf(query,insert,values);
655     r = run_query( hdb, query );
656     HeapFree(GetProcessHeap(), 0, query);
657     return r;
658 }
659
660 static UINT add_media_entry( MSIHANDLE hdb, const char *values )
661 {
662     char insert[] = "INSERT INTO `Media` "
663             "(`DiskId`, `LastSequence`, `DiskPrompt`, `Cabinet`, `VolumeLabel`, `Source`) "
664             "VALUES( %s )";
665     char *query;
666     UINT sz, r;
667
668     sz = strlen(values) + sizeof insert;
669     query = HeapAlloc(GetProcessHeap(),0,sz);
670     sprintf(query,insert,values);
671     r = run_query( hdb, query );
672     HeapFree(GetProcessHeap(), 0, query);
673     return r;
674 }
675
676 static UINT add_ccpsearch_entry( MSIHANDLE hdb, const char *values )
677 {
678     char insert[] = "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )";
679     char *query;
680     UINT sz, r;
681
682     sz = strlen(values) + sizeof insert;
683     query = HeapAlloc(GetProcessHeap(),0,sz);
684     sprintf(query,insert,values);
685     r = run_query( hdb, query );
686     HeapFree(GetProcessHeap(), 0, query);
687     return r;
688 }
689
690 static UINT add_drlocator_entry( MSIHANDLE hdb, const char *values )
691 {
692     char insert[] = "INSERT INTO `DrLocator` "
693             "(`Signature_`, `Parent`, `Path`, `Depth`) "
694             "VALUES( %s )";
695     char *query;
696     UINT sz, r;
697
698     sz = strlen(values) + sizeof insert;
699     query = HeapAlloc(GetProcessHeap(),0,sz);
700     sprintf(query,insert,values);
701     r = run_query( hdb, query );
702     HeapFree(GetProcessHeap(), 0, query);
703     return r;
704 }
705
706 static UINT add_complocator_entry( MSIHANDLE hdb, const char *values )
707 {
708     char insert[] = "INSERT INTO `CompLocator` "
709             "(`Signature_`, `ComponentId`, `Type`) "
710             "VALUES( %s )";
711     char *query;
712     UINT sz, r;
713
714     sz = strlen(values) + sizeof insert;
715     query = HeapAlloc(GetProcessHeap(),0,sz);
716     sprintf(query,insert,values);
717     r = run_query( hdb, query );
718     HeapFree(GetProcessHeap(), 0, query);
719     return r;
720 }
721
722 static UINT add_inilocator_entry( MSIHANDLE hdb, const char *values )
723 {
724     char insert[] = "INSERT INTO `IniLocator` "
725             "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
726             "VALUES( %s )";
727     char *query;
728     UINT sz, r;
729
730     sz = strlen(values) + sizeof insert;
731     query = HeapAlloc(GetProcessHeap(),0,sz);
732     sprintf(query,insert,values);
733     r = run_query( hdb, query );
734     HeapFree(GetProcessHeap(), 0, query);
735     return r;
736 }
737
738 static UINT set_summary_info(MSIHANDLE hdb)
739 {
740     UINT res;
741     MSIHANDLE suminfo;
742
743     /* build summary info */
744     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
745     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
746
747     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
748                         "Installation Database");
749     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
750
751     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
752                         "Installation Database");
753     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
754
755     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
756                         "Wine Hackers");
757     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
758
759     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
760                     ";1033");
761     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
762
763     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
764                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
765     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
766
767     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
768     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
769
770     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
771     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
772
773     res = MsiSummaryInfoPersist(suminfo);
774     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
775
776     res = MsiCloseHandle( suminfo);
777     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
778
779     return res;
780 }
781
782
783 static MSIHANDLE create_package_db(void)
784 {
785     MSIHANDLE hdb = 0;
786     UINT res;
787
788     DeleteFile(msifile);
789
790     /* create an empty database */
791     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
792     ok( res == ERROR_SUCCESS , "Failed to create database\n" );
793     if( res != ERROR_SUCCESS )
794         return hdb;
795
796     res = MsiDatabaseCommit( hdb );
797     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
798
799     res = set_summary_info(hdb);
800
801     res = run_query( hdb,
802             "CREATE TABLE `Directory` ( "
803             "`Directory` CHAR(255) NOT NULL, "
804             "`Directory_Parent` CHAR(255), "
805             "`DefaultDir` CHAR(255) NOT NULL "
806             "PRIMARY KEY `Directory`)" );
807     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
808
809     return hdb;
810 }
811
812 static MSIHANDLE package_from_db(MSIHANDLE hdb)
813 {
814     UINT res;
815     CHAR szPackage[10];
816     MSIHANDLE hPackage;
817
818     sprintf(szPackage,"#%li",hdb);
819     res = MsiOpenPackage(szPackage,&hPackage);
820     if (res != ERROR_SUCCESS)
821         return 0;
822
823     res = MsiCloseHandle(hdb);
824     if (res != ERROR_SUCCESS)
825         return 0;
826
827     return hPackage;
828 }
829
830 static void create_test_file(const CHAR *name)
831 {
832     HANDLE file;
833     DWORD written;
834
835     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
836     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
837     WriteFile(file, name, strlen(name), &written, NULL);
838     WriteFile(file, "\n", strlen("\n"), &written, NULL);
839     CloseHandle(file);
840 }
841
842 static void test_createpackage(void)
843 {
844     MSIHANDLE hPackage = 0;
845     UINT res;
846
847     hPackage = package_from_db(create_package_db());
848     ok( hPackage != 0, " Failed to create package\n");
849
850     res = MsiCloseHandle( hPackage);
851     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
852     DeleteFile(msifile);
853 }
854
855 static void test_doaction( void )
856 {
857     MSIHANDLE hpkg;
858     UINT r;
859
860     r = MsiDoAction( -1, NULL );
861     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
862
863     hpkg = package_from_db(create_package_db());
864     ok( hpkg, "failed to create package\n");
865
866     r = MsiDoAction(hpkg, NULL);
867     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
868
869     r = MsiDoAction(0, "boo");
870     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
871
872     r = MsiDoAction(hpkg, "boo");
873     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
874
875     MsiCloseHandle( hpkg );
876     DeleteFile(msifile);
877 }
878
879 static void test_gettargetpath_bad(void)
880 {
881     char buffer[0x80];
882     MSIHANDLE hpkg;
883     DWORD sz;
884     UINT r;
885
886     hpkg = package_from_db(create_package_db());
887     ok( hpkg, "failed to create package\n");
888
889     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
890     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
891
892     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
893     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
894
895     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
896     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
897
898     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
899     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
900
901     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
902     ok( r == ERROR_DIRECTORY, "wrong return val\n");
903
904     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
905     ok( r == ERROR_DIRECTORY, "wrong return val\n");
906
907     MsiCloseHandle( hpkg );
908     DeleteFile(msifile);
909 }
910
911 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
912 {
913     UINT r;
914     DWORD size;
915     MSIHANDLE rec;
916
917     rec = MsiCreateRecord( 1 );
918     ok(rec, "MsiCreate record failed\n");
919
920     r = MsiRecordSetString( rec, 0, file );
921     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
922
923     size = MAX_PATH;
924     r = MsiFormatRecord( hpkg, rec, buff, &size );
925     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
926
927     MsiCloseHandle( rec );
928 }
929
930 static void test_settargetpath(void)
931 {
932     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
933     DWORD sz;
934     MSIHANDLE hpkg;
935     UINT r;
936     MSIHANDLE hdb;
937
938     hdb = create_package_db();
939     ok ( hdb, "failed to create package database\n" );
940
941     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
942     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
943
944     r = create_component_table( hdb );
945     ok( r == S_OK, "cannot create Component table: %d\n", r );
946
947     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
948     ok( r == S_OK, "cannot add dummy component: %d\n", r );
949
950     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
951     ok( r == S_OK, "cannot add test component: %d\n", r );
952
953     r = create_feature_table( hdb );
954     ok( r == S_OK, "cannot create Feature table: %d\n", r );
955
956     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
957     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
958
959     r = create_feature_components_table( hdb );
960     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
961
962     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
963     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
964
965     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
966     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
967
968     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
969     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
970
971     r = create_file_table( hdb );
972     ok( r == S_OK, "cannot create File table: %d\n", r );
973
974     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
975     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
976
977     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
978     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
979
980     hpkg = package_from_db( hdb );
981     ok( hpkg, "failed to create package\n");
982
983     r = MsiDoAction( hpkg, "CostInitialize");
984     ok( r == ERROR_SUCCESS, "cost init failed\n");
985
986     r = MsiDoAction( hpkg, "FileCost");
987     ok( r == ERROR_SUCCESS, "file cost failed\n");
988
989     r = MsiDoAction( hpkg, "CostFinalize");
990     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
991
992     r = MsiSetTargetPath( 0, NULL, NULL );
993     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
994
995     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
996     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
997
998     r = MsiSetTargetPath( hpkg, "boo", NULL );
999     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1000
1001     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1002     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1003
1004     sz = sizeof tempdir - 1;
1005     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1006     sprintf( file, "%srootfile.txt", tempdir );
1007     query_file_path( hpkg, "[#RootFile]", buffer );
1008     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1009     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1010
1011     GetTempFileName( tempdir, "_wt", 0, buffer );
1012     sprintf( tempdir, "%s\\subdir", buffer );
1013
1014     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1015     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1016         "MsiSetTargetPath on file returned %d\n", r );
1017
1018     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1019     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1020         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1021
1022     DeleteFile( buffer );
1023
1024     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1025     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1026
1027     r = GetFileAttributes( buffer );
1028     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1029
1030     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1031     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1032
1033     sz = sizeof buffer - 1;
1034     lstrcat( tempdir, "\\" );
1035     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1036     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1037     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1038
1039     sprintf( file, "%srootfile.txt", tempdir );
1040     query_file_path( hpkg, "[#RootFile]", buffer );
1041     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1042
1043     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1044     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1045
1046     query_file_path( hpkg, "[#TestFile]", buffer );
1047     ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1048         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1049
1050     sz = sizeof buffer - 1;
1051     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1052     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1053     ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1054
1055     MsiCloseHandle( hpkg );
1056 }
1057
1058 static void test_condition(void)
1059 {
1060     MSICONDITION r;
1061     MSIHANDLE hpkg;
1062
1063     hpkg = package_from_db(create_package_db());
1064     ok( hpkg, "failed to create package\n");
1065
1066     r = MsiEvaluateCondition(0, NULL);
1067     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1068
1069     r = MsiEvaluateCondition(hpkg, NULL);
1070     ok( r == MSICONDITION_NONE, "wrong return val\n");
1071
1072     r = MsiEvaluateCondition(hpkg, "");
1073     ok( r == MSICONDITION_NONE, "wrong return val\n");
1074
1075     r = MsiEvaluateCondition(hpkg, "1");
1076     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1077
1078     r = MsiEvaluateCondition(hpkg, "0");
1079     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1080
1081     r = MsiEvaluateCondition(hpkg, "-1");
1082     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1083
1084     r = MsiEvaluateCondition(hpkg, "0 = 0");
1085     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1086
1087     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1088     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1089
1090     r = MsiEvaluateCondition(hpkg, "0 = 1");
1091     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1092
1093     r = MsiEvaluateCondition(hpkg, "0 > 1");
1094     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1095
1096     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1097     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1098
1099     r = MsiEvaluateCondition(hpkg, "1 > 1");
1100     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1101
1102     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1103     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1104
1105     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1106     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1107
1108     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1109     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1110
1111     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1112     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1113
1114     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1115     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1116
1117     r = MsiEvaluateCondition(hpkg, "0 < 1");
1118     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1119
1120     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1121     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1122
1123     r = MsiEvaluateCondition(hpkg, "1 < 1");
1124     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1125
1126     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1127     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1128
1129     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1130     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1131
1132     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1133     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1134
1135     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1136     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1137
1138     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1139     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1140
1141     r = MsiEvaluateCondition(hpkg, "0 >=");
1142     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1143
1144     r = MsiEvaluateCondition(hpkg, " ");
1145     ok( r == MSICONDITION_NONE, "wrong return val\n");
1146
1147     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1148     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1149
1150     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1151     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1152
1153     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1154     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1155
1156     r = MsiEvaluateCondition(hpkg, "not 0");
1157     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1158
1159     r = MsiEvaluateCondition(hpkg, "not LicView");
1160     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1161
1162     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1163     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1164
1165     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1166     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1167
1168     r = MsiEvaluateCondition(hpkg, "\"0\"");
1169     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1170
1171     r = MsiEvaluateCondition(hpkg, "1 and 2");
1172     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1173
1174     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1175     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1176
1177     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1178     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1179
1180     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1181     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1182
1183     r = MsiEvaluateCondition(hpkg, "(0)");
1184     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1185
1186     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1187     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1188
1189     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1190     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1191
1192     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1193     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1194
1195     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1196     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1197
1198     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1199     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1200
1201     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1202     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1203
1204     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1205     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1206
1207     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1208     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1209
1210     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1211     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1212
1213     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1214     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1215
1216     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1217     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1218
1219     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1220     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1221
1222     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1223     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1224
1225     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1226     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1227
1228     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1229     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1230
1231     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1232     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1233
1234     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1235     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1236
1237     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1238     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1239
1240     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1241     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1242
1243     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1244     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1245
1246     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1247     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1248
1249     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1250     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1251
1252     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1253     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1254
1255     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1256     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1257
1258     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1259     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1260
1261     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1262     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1263
1264     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1265     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1266
1267     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1268     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1269
1270     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1271     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1272
1273     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1274     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1275
1276     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1277     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1278
1279     MsiSetProperty(hpkg, "mm", "5" );
1280
1281     r = MsiEvaluateCondition(hpkg, "mm = 5");
1282     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1283
1284     r = MsiEvaluateCondition(hpkg, "mm < 6");
1285     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1286
1287     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1288     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1289
1290     r = MsiEvaluateCondition(hpkg, "mm > 4");
1291     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1292
1293     r = MsiEvaluateCondition(hpkg, "mm < 12");
1294     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1295
1296     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1297     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1298
1299     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1300     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1301
1302     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1303     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1304
1305     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1306     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1307
1308     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1309     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1310
1311     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1312     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1313
1314     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1315     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1316
1317     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1318     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1319
1320     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1321     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1322
1323     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1324     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1325
1326     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1327     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1328
1329     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1330     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1331
1332     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1333     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1334
1335     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1336     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1337
1338     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1339     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1340
1341     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1342     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1343
1344     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1345     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1346
1347     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1348     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1349
1350     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1351     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1352
1353     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1354     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1355
1356     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1357     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1358
1359     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1360     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1361
1362     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1363     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1364
1365     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1366     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1367
1368     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1369     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1370
1371     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1372     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1373
1374     MsiSetProperty(hpkg, "bandalmael", "0" );
1375     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1376     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1377
1378     MsiSetProperty(hpkg, "bandalmael", "" );
1379     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1380     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1381
1382     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1383     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1384     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1385
1386     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1387     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1388     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1389
1390     MsiSetProperty(hpkg, "bandalmael", "0 " );
1391     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1392     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1393
1394     MsiSetProperty(hpkg, "bandalmael", "-0" );
1395     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1396     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1397
1398     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1399     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1400     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1401
1402     MsiSetProperty(hpkg, "bandalmael", "--0" );
1403     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1404     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1405
1406     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1407     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1408     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1409
1410     MsiSetProperty(hpkg, "bandalmael", "-" );
1411     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1412     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1413
1414     MsiSetProperty(hpkg, "bandalmael", "+0" );
1415     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1416     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1417
1418     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1419     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1420     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1421     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1422     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1423
1424     MsiSetProperty(hpkg, "one", "hi");
1425     MsiSetProperty(hpkg, "two", "hithere");
1426     r = MsiEvaluateCondition(hpkg, "one >< two");
1427     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1428
1429     MsiSetProperty(hpkg, "one", "hithere");
1430     MsiSetProperty(hpkg, "two", "hi");
1431     r = MsiEvaluateCondition(hpkg, "one >< two");
1432     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1433
1434     MsiSetProperty(hpkg, "one", "hello");
1435     MsiSetProperty(hpkg, "two", "hi");
1436     r = MsiEvaluateCondition(hpkg, "one >< two");
1437     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1438
1439     MsiSetProperty(hpkg, "one", "hellohithere");
1440     MsiSetProperty(hpkg, "two", "hi");
1441     r = MsiEvaluateCondition(hpkg, "one >< two");
1442     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444     MsiSetProperty(hpkg, "one", "");
1445     MsiSetProperty(hpkg, "two", "hi");
1446     r = MsiEvaluateCondition(hpkg, "one >< two");
1447     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1448
1449     MsiSetProperty(hpkg, "one", "hi");
1450     MsiSetProperty(hpkg, "two", "");
1451     r = MsiEvaluateCondition(hpkg, "one >< two");
1452     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1453
1454     MsiSetProperty(hpkg, "one", "");
1455     MsiSetProperty(hpkg, "two", "");
1456     r = MsiEvaluateCondition(hpkg, "one >< two");
1457     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1458
1459     MsiSetProperty(hpkg, "one", "1234");
1460     MsiSetProperty(hpkg, "two", "1");
1461     r = MsiEvaluateCondition(hpkg, "one >< two");
1462     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1463
1464     MsiSetProperty(hpkg, "one", "one 1234");
1465     MsiSetProperty(hpkg, "two", "1");
1466     r = MsiEvaluateCondition(hpkg, "one >< two");
1467     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1468
1469     MsiSetProperty(hpkg, "one", "hithere");
1470     MsiSetProperty(hpkg, "two", "hi");
1471     r = MsiEvaluateCondition(hpkg, "one << two");
1472     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1473
1474     MsiSetProperty(hpkg, "one", "hi");
1475     MsiSetProperty(hpkg, "two", "hithere");
1476     r = MsiEvaluateCondition(hpkg, "one << two");
1477     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1478
1479     MsiSetProperty(hpkg, "one", "hi");
1480     MsiSetProperty(hpkg, "two", "hi");
1481     r = MsiEvaluateCondition(hpkg, "one << two");
1482     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1483
1484     MsiSetProperty(hpkg, "one", "abcdhithere");
1485     MsiSetProperty(hpkg, "two", "hi");
1486     r = MsiEvaluateCondition(hpkg, "one << two");
1487     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1488
1489     MsiSetProperty(hpkg, "one", "");
1490     MsiSetProperty(hpkg, "two", "hi");
1491     r = MsiEvaluateCondition(hpkg, "one << two");
1492     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1493
1494     MsiSetProperty(hpkg, "one", "hithere");
1495     MsiSetProperty(hpkg, "two", "");
1496     r = MsiEvaluateCondition(hpkg, "one << two");
1497     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1498
1499     MsiSetProperty(hpkg, "one", "");
1500     MsiSetProperty(hpkg, "two", "");
1501     r = MsiEvaluateCondition(hpkg, "one << two");
1502     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1503
1504     MsiSetProperty(hpkg, "one", "1234");
1505     MsiSetProperty(hpkg, "two", "1");
1506     r = MsiEvaluateCondition(hpkg, "one << two");
1507     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1508
1509     MsiSetProperty(hpkg, "one", "1234 one");
1510     MsiSetProperty(hpkg, "two", "1");
1511     r = MsiEvaluateCondition(hpkg, "one << two");
1512     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1513
1514     MsiSetProperty(hpkg, "one", "hithere");
1515     MsiSetProperty(hpkg, "two", "there");
1516     r = MsiEvaluateCondition(hpkg, "one >> two");
1517     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1518
1519     MsiSetProperty(hpkg, "one", "hithere");
1520     MsiSetProperty(hpkg, "two", "hi");
1521     r = MsiEvaluateCondition(hpkg, "one >> two");
1522     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1523
1524     MsiSetProperty(hpkg, "one", "there");
1525     MsiSetProperty(hpkg, "two", "hithere");
1526     r = MsiEvaluateCondition(hpkg, "one >> two");
1527     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1528
1529     MsiSetProperty(hpkg, "one", "there");
1530     MsiSetProperty(hpkg, "two", "there");
1531     r = MsiEvaluateCondition(hpkg, "one >> two");
1532     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1533
1534     MsiSetProperty(hpkg, "one", "abcdhithere");
1535     MsiSetProperty(hpkg, "two", "hi");
1536     r = MsiEvaluateCondition(hpkg, "one >> two");
1537     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1538
1539     MsiSetProperty(hpkg, "one", "");
1540     MsiSetProperty(hpkg, "two", "there");
1541     r = MsiEvaluateCondition(hpkg, "one >> two");
1542     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1543
1544     MsiSetProperty(hpkg, "one", "there");
1545     MsiSetProperty(hpkg, "two", "");
1546     r = MsiEvaluateCondition(hpkg, "one >> two");
1547     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1548
1549     MsiSetProperty(hpkg, "one", "");
1550     MsiSetProperty(hpkg, "two", "");
1551     r = MsiEvaluateCondition(hpkg, "one >> two");
1552     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1553
1554     MsiSetProperty(hpkg, "one", "1234");
1555     MsiSetProperty(hpkg, "two", "4");
1556     r = MsiEvaluateCondition(hpkg, "one >> two");
1557     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1558
1559     MsiSetProperty(hpkg, "one", "one 1234");
1560     MsiSetProperty(hpkg, "two", "4");
1561     r = MsiEvaluateCondition(hpkg, "one >> two");
1562     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1563
1564     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1565
1566     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1567     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1568
1569     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1570     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1571
1572     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1573     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1574
1575     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1576     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1577
1578     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1579     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1580
1581     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1582     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1583
1584     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1585     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1586
1587     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1588     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1589
1590     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1591     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1592
1593     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1594     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1595
1596     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1597     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1598
1599     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1600     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1601
1602     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1603     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1604
1605     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1606     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1607
1608     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1609     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1610
1611     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1612     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1613
1614     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1615     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1616
1617     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1618     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1619
1620     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1621     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1622
1623     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1624     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1625
1626     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1627     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1628
1629     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1630     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1631
1632     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1633     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1634
1635     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1636     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1637
1638     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1639     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1640
1641     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1642     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1643
1644     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1645     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1646
1647     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1648     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1649
1650     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1651     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1652
1653     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1654     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1655
1656     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1657     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1658
1659     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1660     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1661
1662     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1663     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1664
1665     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1666     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1667
1668     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1669     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1670
1671     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1672     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1673
1674     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1675     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1676
1677     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1678     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1679     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1680
1681     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1682     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1683
1684     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1685     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1686
1687     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1688     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1689
1690     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1691     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1692
1693     MsiSetProperty(hpkg, "one", "1");
1694     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1695     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1696
1697     MsiSetProperty(hpkg, "X", "5.0");
1698
1699     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1700     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1701
1702     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1703     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1704
1705     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1706     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1707
1708     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1709     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1710
1711     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1712     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1713
1714     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1715     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1716
1717     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1718     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1719
1720     /* feature doesn't exist */
1721     r = MsiEvaluateCondition(hpkg, "&nofeature");
1722     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1723
1724     MsiSetProperty(hpkg, "A", "2");
1725     MsiSetProperty(hpkg, "X", "50");
1726
1727     r = MsiEvaluateCondition(hpkg, "2 <= X");
1728     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1729
1730     r = MsiEvaluateCondition(hpkg, "A <= X");
1731     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1732
1733     r = MsiEvaluateCondition(hpkg, "A <= 50");
1734     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1735
1736     MsiSetProperty(hpkg, "X", "50val");
1737
1738     r = MsiEvaluateCondition(hpkg, "2 <= X");
1739     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1740
1741     r = MsiEvaluateCondition(hpkg, "A <= X");
1742     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1743
1744     MsiSetProperty(hpkg, "A", "7");
1745     MsiSetProperty(hpkg, "X", "50");
1746
1747     r = MsiEvaluateCondition(hpkg, "7 <= X");
1748     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749
1750     r = MsiEvaluateCondition(hpkg, "A <= X");
1751     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1752
1753     r = MsiEvaluateCondition(hpkg, "A <= 50");
1754     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1755
1756     MsiSetProperty(hpkg, "X", "50val");
1757
1758     r = MsiEvaluateCondition(hpkg, "2 <= X");
1759     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1760
1761     r = MsiEvaluateCondition(hpkg, "A <= X");
1762     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1763
1764     MsiCloseHandle( hpkg );
1765     DeleteFile(msifile);
1766 }
1767
1768 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1769 {
1770     UINT r;
1771     DWORD sz;
1772     char buffer[2];
1773
1774     sz = sizeof buffer;
1775     strcpy(buffer,"x");
1776     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1777     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1778 }
1779
1780 static void test_props(void)
1781 {
1782     MSIHANDLE hpkg, hdb;
1783     UINT r;
1784     DWORD sz;
1785     char buffer[0x100];
1786
1787     hdb = create_package_db();
1788     r = run_query( hdb,
1789             "CREATE TABLE `Property` ( "
1790             "`Property` CHAR(255) NOT NULL, "
1791             "`Value` CHAR(255) "
1792             "PRIMARY KEY `Property`)" );
1793     ok( r == ERROR_SUCCESS , "Failed\n" );
1794
1795     r = run_query(hdb,
1796             "INSERT INTO `Property` "
1797             "(`Property`, `Value`) "
1798             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1799     ok( r == ERROR_SUCCESS , "Failed\n" );
1800
1801     hpkg = package_from_db( hdb );
1802     ok( hpkg, "failed to create package\n");
1803
1804     /* test invalid values */
1805     r = MsiGetProperty( 0, NULL, NULL, NULL );
1806     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1807
1808     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1809     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1810
1811     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1812     ok( r == ERROR_SUCCESS, "wrong return val\n");
1813
1814     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1815     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1816
1817     /* test retrieving an empty/nonexistent property */
1818     sz = sizeof buffer;
1819     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1820     ok( r == ERROR_SUCCESS, "wrong return val\n");
1821     ok( sz == 0, "wrong size returned\n");
1822
1823     check_prop_empty( hpkg, "boo");
1824     sz = 0;
1825     strcpy(buffer,"x");
1826     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1827     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1828     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1829     ok( sz == 0, "wrong size returned\n");
1830
1831     sz = 1;
1832     strcpy(buffer,"x");
1833     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1834     ok( r == ERROR_SUCCESS, "wrong return val\n");
1835     ok( buffer[0] == 0, "buffer was not changed\n");
1836     ok( sz == 0, "wrong size returned\n");
1837
1838     /* set the property to something */
1839     r = MsiSetProperty( 0, NULL, NULL );
1840     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1841
1842     r = MsiSetProperty( hpkg, NULL, NULL );
1843     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1844
1845     r = MsiSetProperty( hpkg, "", NULL );
1846     ok( r == ERROR_SUCCESS, "wrong return val\n");
1847
1848     /* try set and get some illegal property identifiers */
1849     r = MsiSetProperty( hpkg, "", "asdf" );
1850     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1851
1852     r = MsiSetProperty( hpkg, "=", "asdf" );
1853     ok( r == ERROR_SUCCESS, "wrong return val\n");
1854
1855     r = MsiSetProperty( hpkg, " ", "asdf" );
1856     ok( r == ERROR_SUCCESS, "wrong return val\n");
1857
1858     r = MsiSetProperty( hpkg, "'", "asdf" );
1859     ok( r == ERROR_SUCCESS, "wrong return val\n");
1860
1861     sz = sizeof buffer;
1862     buffer[0]=0;
1863     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1864     ok( r == ERROR_SUCCESS, "wrong return val\n");
1865     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1866
1867     /* set empty values */
1868     r = MsiSetProperty( hpkg, "boo", NULL );
1869     ok( r == ERROR_SUCCESS, "wrong return val\n");
1870     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1871
1872     r = MsiSetProperty( hpkg, "boo", "" );
1873     ok( r == ERROR_SUCCESS, "wrong return val\n");
1874     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1875
1876     /* set a non-empty value */
1877     r = MsiSetProperty( hpkg, "boo", "xyz" );
1878     ok( r == ERROR_SUCCESS, "wrong return val\n");
1879
1880     sz = 1;
1881     strcpy(buffer,"x");
1882     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1883     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1884     ok( buffer[0] == 0, "buffer was not changed\n");
1885     ok( sz == 3, "wrong size returned\n");
1886
1887     sz = 4;
1888     strcpy(buffer,"x");
1889     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1890     ok( r == ERROR_SUCCESS, "wrong return val\n");
1891     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1892     ok( sz == 3, "wrong size returned\n");
1893
1894     sz = 3;
1895     strcpy(buffer,"x");
1896     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1897     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1898     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1899     ok( sz == 3, "wrong size returned\n");
1900
1901     r = MsiSetProperty(hpkg, "SourceDir", "foo");
1902     ok( r == ERROR_SUCCESS, "wrong return val\n");
1903
1904     sz = 4;
1905     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1906     ok( r == ERROR_SUCCESS, "wrong return val\n");
1907     ok( !strcmp(buffer,""), "buffer wrong\n");
1908     ok( sz == 0, "wrong size returned\n");
1909
1910     sz = 4;
1911     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1912     ok( r == ERROR_SUCCESS, "wrong return val\n");
1913     ok( !strcmp(buffer,""), "buffer wrong\n");
1914     ok( sz == 0, "wrong size returned\n");
1915
1916     sz = 4;
1917     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1918     ok( r == ERROR_SUCCESS, "wrong return val\n");
1919     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1920     ok( sz == 3, "wrong size returned\n");
1921
1922     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1923     ok( r == ERROR_SUCCESS, "wrong return val\n");
1924
1925     sz = 0;
1926     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1927     ok( r == ERROR_SUCCESS, "return wrong\n");
1928     ok( sz == 13, "size wrong (%d)\n", sz);
1929
1930     sz = 13;
1931     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1932     ok( r == ERROR_MORE_DATA, "return wrong\n");
1933     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1934
1935     r = MsiSetProperty(hpkg, "property", "value");
1936     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1937
1938     sz = 6;
1939     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1940     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1941     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1942
1943     r = MsiSetProperty(hpkg, "property", NULL);
1944     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1945
1946     sz = 6;
1947     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1948     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1949     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1950
1951     MsiCloseHandle( hpkg );
1952     DeleteFile(msifile);
1953 }
1954
1955 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
1956 {
1957     MSIHANDLE hview, hrec;
1958     BOOL found;
1959     CHAR buffer[MAX_PATH];
1960     DWORD sz;
1961     UINT r;
1962
1963     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
1964     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1965     r = MsiViewExecute(hview, 0);
1966     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
1967
1968     found = FALSE;
1969     while (r == ERROR_SUCCESS && !found)
1970     {
1971         r = MsiViewFetch(hview, &hrec);
1972         if (r != ERROR_SUCCESS) break;
1973
1974         sz = MAX_PATH;
1975         r = MsiRecordGetString(hrec, 1, buffer, &sz);
1976         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
1977         {
1978             sz = MAX_PATH;
1979             r = MsiRecordGetString(hrec, 2, buffer, &sz);
1980             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
1981                 found = TRUE;
1982         }
1983
1984         MsiCloseHandle(hrec);
1985     }
1986
1987     MsiViewClose(hview);
1988     MsiCloseHandle(hview);
1989
1990     return found;
1991 }
1992
1993 static void test_property_table(void)
1994 {
1995     const char *query;
1996     UINT r;
1997     MSIHANDLE hpkg, hdb, hrec;
1998     char buffer[MAX_PATH];
1999     DWORD sz;
2000     BOOL found;
2001
2002     hdb = create_package_db();
2003     ok( hdb, "failed to create package\n");
2004
2005     hpkg = package_from_db(hdb);
2006     ok( hpkg, "failed to create package\n");
2007
2008     MsiCloseHandle(hdb);
2009
2010     hdb = MsiGetActiveDatabase(hpkg);
2011
2012     query = "CREATE TABLE `_Property` ( "
2013         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2014     r = run_query(hdb, query);
2015     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2016
2017     MsiCloseHandle(hdb);
2018     MsiCloseHandle(hpkg);
2019     DeleteFile(msifile);
2020
2021     hdb = create_package_db();
2022     ok( hdb, "failed to create package\n");
2023
2024     query = "CREATE TABLE `_Property` ( "
2025         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2026     r = run_query(hdb, query);
2027     ok(r == ERROR_SUCCESS, "failed to create table\n");
2028
2029     query = "ALTER `_Property` ADD `foo` INTEGER";
2030     r = run_query(hdb, query);
2031     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2032
2033     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2034     r = run_query(hdb, query);
2035     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2036
2037     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2038     r = run_query(hdb, query);
2039     ok(r == ERROR_SUCCESS, "failed to add column\n");
2040
2041     hpkg = package_from_db(hdb);
2042     todo_wine
2043     {
2044         ok(!hpkg, "package should not be created\n");
2045     }
2046
2047     MsiCloseHandle(hdb);
2048     MsiCloseHandle(hpkg);
2049     DeleteFile(msifile);
2050
2051     hdb = create_package_db();
2052     ok (hdb, "failed to create package database\n");
2053
2054     r = create_property_table(hdb);
2055     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2056
2057     r = add_property_entry(hdb, "'prop', 'val'");
2058     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2059
2060     hpkg = package_from_db(hdb);
2061     ok(hpkg, "failed to create package\n");
2062
2063     MsiCloseHandle(hdb);
2064
2065     sz = MAX_PATH;
2066     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2067     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2068     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2069
2070     hdb = MsiGetActiveDatabase(hpkg);
2071
2072     found = find_prop_in_property(hdb, "prop", "val");
2073     ok(found, "prop should be in the _Property table\n");
2074
2075     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2076     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2077
2078     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2079     r = do_query(hdb, query, &hrec);
2080     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2081
2082     found = find_prop_in_property(hdb, "dantes", "mercedes");
2083     ok(found == FALSE, "dantes should not be in the _Property table\n");
2084
2085     sz = MAX_PATH;
2086     lstrcpy(buffer, "aaa");
2087     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2088     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2089     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2090
2091     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2093
2094     found = find_prop_in_property(hdb, "dantes", "mercedes");
2095     ok(found == TRUE, "dantes should be in the _Property table\n");
2096
2097     MsiCloseHandle(hdb);
2098     MsiCloseHandle(hpkg);
2099     DeleteFile(msifile);
2100 }
2101
2102 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2103 {
2104     MSIHANDLE htab = 0;
2105     UINT res;
2106
2107     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2108     if( res == ERROR_SUCCESS )
2109     {
2110         UINT r;
2111
2112         r = MsiViewExecute( htab, hrec );
2113         if( r != ERROR_SUCCESS )
2114         {
2115             res = r;
2116             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2117         }
2118
2119         r = MsiViewClose( htab );
2120         if( r != ERROR_SUCCESS )
2121             res = r;
2122
2123         r = MsiCloseHandle( htab );
2124         if( r != ERROR_SUCCESS )
2125             res = r;
2126     }
2127     return res;
2128 }
2129
2130 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2131 {
2132     return try_query_param( hdb, szQuery, 0 );
2133 }
2134
2135 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2136 {
2137     MSIHANDLE summary;
2138     UINT r;
2139
2140     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2141     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2142
2143     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2144     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2145
2146     r = MsiSummaryInfoPersist(summary);
2147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2148
2149     MsiCloseHandle(summary);
2150 }
2151
2152 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2153 {
2154     MSIHANDLE summary;
2155     UINT r;
2156
2157     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2158     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2159
2160     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2161     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2162
2163     r = MsiSummaryInfoPersist(summary);
2164     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2165
2166     MsiCloseHandle(summary);
2167 }
2168
2169 static void test_msipackage(void)
2170 {
2171     MSIHANDLE hdb = 0, hpack = 100;
2172     UINT r;
2173     const char *query;
2174     char name[10];
2175
2176     /* NULL szPackagePath */
2177     r = MsiOpenPackage(NULL, &hpack);
2178     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2179
2180     /* empty szPackagePath */
2181     r = MsiOpenPackage("", &hpack);
2182     todo_wine
2183     {
2184         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2185     }
2186
2187     if (r == ERROR_SUCCESS)
2188         MsiCloseHandle(hpack);
2189
2190     /* nonexistent szPackagePath */
2191     r = MsiOpenPackage("nonexistent", &hpack);
2192     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2193
2194     /* NULL hProduct */
2195     r = MsiOpenPackage(msifile, NULL);
2196     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2197
2198     name[0]='#';
2199     name[1]=0;
2200     r = MsiOpenPackage(name, &hpack);
2201     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2202
2203     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2204     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2205
2206     /* database exists, but is emtpy */
2207     sprintf(name, "#%ld", hdb);
2208     r = MsiOpenPackage(name, &hpack);
2209     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2210        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2211
2212     query = "CREATE TABLE `Property` ( "
2213             "`Property` CHAR(72), `Value` CHAR(0) "
2214             "PRIMARY KEY `Property`)";
2215     r = try_query(hdb, query);
2216     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2217
2218     query = "CREATE TABLE `InstallExecuteSequence` ("
2219             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2220             "PRIMARY KEY `Action`)";
2221     r = try_query(hdb, query);
2222     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2223
2224     /* a few key tables exist */
2225     sprintf(name, "#%ld", hdb);
2226     r = MsiOpenPackage(name, &hpack);
2227     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2228        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2229
2230     MsiCloseHandle(hdb);
2231     DeleteFile(msifile);
2232
2233     /* start with a clean database to show what constitutes a valid package */
2234     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2235     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2236
2237     sprintf(name, "#%ld", hdb);
2238
2239     /* The following summary information props must exist:
2240      *  - PID_REVNUMBER
2241      *  - PID_PAGECOUNT
2242      */
2243
2244     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2245     r = MsiOpenPackage(name, &hpack);
2246     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2247        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2248
2249     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2250     r = MsiOpenPackage(name, &hpack);
2251     ok(r == ERROR_SUCCESS,
2252        "Expected ERROR_SUCCESS, got %d\n", r);
2253
2254     MsiCloseHandle(hpack);
2255     MsiCloseHandle(hdb);
2256     DeleteFile(msifile);
2257 }
2258
2259 static void test_formatrecord2(void)
2260 {
2261     MSIHANDLE hpkg, hrec ;
2262     char buffer[0x100];
2263     DWORD sz;
2264     UINT r;
2265
2266     hpkg = package_from_db(create_package_db());
2267     ok( hpkg, "failed to create package\n");
2268
2269     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2270     ok( r == ERROR_SUCCESS, "set property failed\n");
2271
2272     hrec = MsiCreateRecord(2);
2273     ok(hrec, "create record failed\n");
2274
2275     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2276     ok( r == ERROR_SUCCESS, "format record failed\n");
2277
2278     buffer[0] = 0;
2279     sz = sizeof buffer;
2280     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2281
2282     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2283     r = MsiRecordSetString(hrec, 1, "hoo");
2284     sz = sizeof buffer;
2285     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2286     ok( sz == 3, "size wrong\n");
2287     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2288     ok( r == ERROR_SUCCESS, "format failed\n");
2289
2290     r = MsiRecordSetString(hrec, 0, "x[~]x");
2291     sz = sizeof buffer;
2292     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2293     ok( sz == 3, "size wrong\n");
2294     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2295     ok( r == ERROR_SUCCESS, "format failed\n");
2296
2297     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2298     r = MsiRecordSetString(hrec, 1, "hoo");
2299     sz = sizeof buffer;
2300     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2301     ok( sz == 3, "size wrong\n");
2302     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2303     ok( r == ERROR_SUCCESS, "format failed\n");
2304
2305     r = MsiRecordSetString(hrec, 0, "[\\[]");
2306     sz = sizeof buffer;
2307     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2308     ok( sz == 1, "size wrong\n");
2309     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2310     ok( r == ERROR_SUCCESS, "format failed\n");
2311
2312     SetEnvironmentVariable("FOO", "BAR");
2313     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2314     sz = sizeof buffer;
2315     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2316     ok( sz == 3, "size wrong\n");
2317     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2318     ok( r == ERROR_SUCCESS, "format failed\n");
2319
2320     r = MsiRecordSetString(hrec, 0, "[[1]]");
2321     r = MsiRecordSetString(hrec, 1, "%FOO");
2322     sz = sizeof buffer;
2323     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2324     ok( sz == 3, "size wrong\n");
2325     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2326     ok( r == ERROR_SUCCESS, "format failed\n");
2327
2328     MsiCloseHandle( hrec );
2329     MsiCloseHandle( hpkg );
2330     DeleteFile(msifile);
2331 }
2332
2333 static void test_states(void)
2334 {
2335     MSIHANDLE hpkg;
2336     UINT r;
2337     MSIHANDLE hdb;
2338     INSTALLSTATE state, action;
2339
2340     static const CHAR msifile2[] = "winetest2.msi";
2341     static const CHAR msifile3[] = "winetest3.msi";
2342
2343     hdb = create_package_db();
2344     ok ( hdb, "failed to create package database\n" );
2345
2346     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2347     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2348
2349     r = create_property_table( hdb );
2350     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2351
2352     r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2353     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2354
2355     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2356     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2357
2358     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2359     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2360
2361     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2362     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2363
2364     r = create_install_execute_sequence_table( hdb );
2365     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2366
2367     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2368     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2369
2370     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2371     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2372
2373     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2374     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2375
2376     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2377     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2378
2379     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2380     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2381
2382     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2383     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2384
2385     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2386     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2387
2388     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2389     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2390
2391     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2392     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2393
2394     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2395     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2396
2397     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2398     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2399
2400     r = create_media_table( hdb );
2401     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2402
2403     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2404     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2405
2406     r = create_feature_table( hdb );
2407     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2408
2409     r = create_component_table( hdb );
2410     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2411
2412     /* msidbFeatureAttributesFavorLocal */
2413     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2414     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2415
2416     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2417     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2418     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2419
2420     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2421     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2422     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2423
2424     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2425     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2426     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2427
2428     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2429     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2430     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2431
2432     /* msidbFeatureAttributesFavorSource */
2433     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2434     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2435
2436     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2437     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2438     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2439
2440     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2441     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2442     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2443
2444     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2445     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2446     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2447
2448     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2449     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2450     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2451
2452     /* msidbFeatureAttributesFavorSource */
2453     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2454     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2455
2456     /* msidbFeatureAttributesFavorLocal */
2457     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2458     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2459
2460     /* disabled */
2461     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2462     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2463
2464     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2465     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2466     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2467
2468     /* no feature parent:msidbComponentAttributesLocalOnly */
2469     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2470     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2471
2472     /* msidbFeatureAttributesFavorLocal:removed */
2473     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2474     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2475
2476     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2477     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2478     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2479
2480     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2481     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2482     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2483
2484     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2485     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2486     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2487
2488     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2489     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2490     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2491
2492     /* msidbFeatureAttributesFavorSource:removed */
2493     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2494     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2495
2496     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2497     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2498     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2499
2500     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2501     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2502     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2503
2504     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2505     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2506     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2507
2508     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2509     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2510     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2511
2512     r = create_feature_components_table( hdb );
2513     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2514
2515     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2516     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2517
2518     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2519     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2520
2521     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2522     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2523
2524     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2525     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2526
2527     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2528     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2529
2530     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2531     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2532
2533     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2534     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2535
2536     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2537     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2538
2539     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2540     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2541
2542     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2543     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2544
2545     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2546     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2547
2548     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2549     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2550
2551     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2552     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2553
2554     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2555     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2556
2557     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2558     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2559
2560     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2561     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2562
2563     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2564     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2565
2566     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2567     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2568
2569     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2570     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2571
2572     r = create_file_table( hdb );
2573     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2574
2575     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2576     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2577
2578     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2579     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2580
2581     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2582     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2583
2584     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2585     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2586
2587     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2588     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2589
2590     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2591     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2592
2593     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2594     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2595
2596     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2597     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2598
2599     /* compressed file */
2600     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2601     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2602
2603     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2604     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2605
2606     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2607     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2608
2609     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2610     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2611
2612     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2613     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2614
2615     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2616     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2617
2618     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2619     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2620
2621     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2622     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2623
2624     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2625     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2626
2627     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2628     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2629
2630     MsiDatabaseCommit(hdb);
2631
2632     /* these properties must not be in the saved msi file */
2633     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2634     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2635
2636     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2637     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2638
2639     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2640     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2641
2642     hpkg = package_from_db( hdb );
2643     ok( hpkg, "failed to create package\n");
2644
2645     MsiCloseHandle(hdb);
2646
2647     CopyFileA(msifile, msifile2, FALSE);
2648     CopyFileA(msifile, msifile3, FALSE);
2649
2650     state = 0xdeadbee;
2651     action = 0xdeadbee;
2652     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2653     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2654     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2655     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2656
2657     state = 0xdeadbee;
2658     action = 0xdeadbee;
2659     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2660     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2661     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2662     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2663
2664     state = 0xdeadbee;
2665     action = 0xdeadbee;
2666     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2667     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2668     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2669     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2670
2671     state = 0xdeadbee;
2672     action = 0xdeadbee;
2673     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2674     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2675     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2676     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2677
2678     state = 0xdeadbee;
2679     action = 0xdeadbee;
2680     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2681     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2682     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2683     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2684
2685     state = 0xdeadbee;
2686     action = 0xdeadbee;
2687     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2688     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2689     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2690     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2691
2692     state = 0xdeadbee;
2693     action = 0xdeadbee;
2694     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2695     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2696     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2697     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2698
2699     state = 0xdeadbee;
2700     action = 0xdeadbee;
2701     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2702     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2703     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2704     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2705
2706     state = 0xdeadbee;
2707     action = 0xdeadbee;
2708     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2709     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2710     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2711     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2712
2713     state = 0xdeadbee;
2714     action = 0xdeadbee;
2715     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2716     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2717     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2718     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2719
2720     state = 0xdeadbee;
2721     action = 0xdeadbee;
2722     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2723     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2724     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2725     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2726
2727     state = 0xdeadbee;
2728     action = 0xdeadbee;
2729     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2730     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2731     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2732     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2733
2734     state = 0xdeadbee;
2735     action = 0xdeadbee;
2736     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2737     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2738     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2739     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2740
2741     state = 0xdeadbee;
2742     action = 0xdeadbee;
2743     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2744     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2745     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2746     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2747
2748     state = 0xdeadbee;
2749     action = 0xdeadbee;
2750     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2751     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2752     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2753     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2754
2755     state = 0xdeadbee;
2756     action = 0xdeadbee;
2757     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2758     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2759     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2760     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2761
2762     state = 0xdeadbee;
2763     action = 0xdeadbee;
2764     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2765     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2766     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2767     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2768
2769     state = 0xdeadbee;
2770     action = 0xdeadbee;
2771     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2772     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2773     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2774     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2775
2776     state = 0xdeadbee;
2777     action = 0xdeadbee;
2778     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2779     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2780     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2781     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2782
2783     state = 0xdeadbee;
2784     action = 0xdeadbee;
2785     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2786     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2787     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2788     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2789
2790     state = 0xdeadbee;
2791     action = 0xdeadbee;
2792     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2793     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2794     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2795     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2796
2797     state = 0xdeadbee;
2798     action = 0xdeadbee;
2799     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2800     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2801     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2802     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2803
2804     state = 0xdeadbee;
2805     action = 0xdeadbee;
2806     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2807     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2808     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2809     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2810
2811     state = 0xdeadbee;
2812     action = 0xdeadbee;
2813     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2814     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2815     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2816     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2817
2818     state = 0xdeadbee;
2819     action = 0xdeadbee;
2820     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2821     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2822     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2823     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2824
2825     r = MsiDoAction( hpkg, "CostInitialize");
2826     ok( r == ERROR_SUCCESS, "cost init failed\n");
2827
2828     state = 0xdeadbee;
2829     action = 0xdeadbee;
2830     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2831     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2832     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2833     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2834
2835     state = 0xdeadbee;
2836     action = 0xdeadbee;
2837     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2838     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2839     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2840     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2841
2842     state = 0xdeadbee;
2843     action = 0xdeadbee;
2844     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2845     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2846     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2847     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2848
2849     state = 0xdeadbee;
2850     action = 0xdeadbee;
2851     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2852     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2853     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2854     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2855
2856     state = 0xdeadbee;
2857     action = 0xdeadbee;
2858     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2859     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2860     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2861     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2862
2863     state = 0xdeadbee;
2864     action = 0xdeadbee;
2865     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2866     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2867     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2868     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2869
2870     state = 0xdeadbee;
2871     action = 0xdeadbee;
2872     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2873     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2874     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2875     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2876
2877     state = 0xdeadbee;
2878     action = 0xdeadbee;
2879     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2880     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2881     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2882     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2883
2884     state = 0xdeadbee;
2885     action = 0xdeadbee;
2886     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2887     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2888     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2889     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2890
2891     state = 0xdeadbee;
2892     action = 0xdeadbee;
2893     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2894     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2895     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2896     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2897
2898     state = 0xdeadbee;
2899     action = 0xdeadbee;
2900     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2901     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2902     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2903     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2904
2905     state = 0xdeadbee;
2906     action = 0xdeadbee;
2907     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2908     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2909     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2910     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2911
2912     state = 0xdeadbee;
2913     action = 0xdeadbee;
2914     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2915     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2916     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2917     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2918
2919     state = 0xdeadbee;
2920     action = 0xdeadbee;
2921     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2922     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2923     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2924     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2925
2926     state = 0xdeadbee;
2927     action = 0xdeadbee;
2928     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2929     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2930     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2931     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2932
2933     state = 0xdeadbee;
2934     action = 0xdeadbee;
2935     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2936     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2937     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2938     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2939
2940     state = 0xdeadbee;
2941     action = 0xdeadbee;
2942     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2943     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2944     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2945     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2946
2947     state = 0xdeadbee;
2948     action = 0xdeadbee;
2949     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2950     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2951     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2952     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2953
2954     state = 0xdeadbee;
2955     action = 0xdeadbee;
2956     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2957     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2958     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2959     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2960
2961     state = 0xdeadbee;
2962     action = 0xdeadbee;
2963     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2964     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2965     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2966     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2967
2968     state = 0xdeadbee;
2969     action = 0xdeadbee;
2970     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2971     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2972     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2973     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2974
2975     state = 0xdeadbee;
2976     action = 0xdeadbee;
2977     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2978     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2979     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2980     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2981
2982     state = 0xdeadbee;
2983     action = 0xdeadbee;
2984     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2985     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2986     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2987     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2988
2989     state = 0xdeadbee;
2990     action = 0xdeadbee;
2991     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2992     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2993     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2994     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2995
2996     state = 0xdeadbee;
2997     action = 0xdeadbee;
2998     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2999     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3000     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3001     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3002
3003     r = MsiDoAction( hpkg, "FileCost");
3004     ok( r == ERROR_SUCCESS, "file cost failed\n");
3005
3006     state = 0xdeadbee;
3007     action = 0xdeadbee;
3008     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3009     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3010     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3011     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3012
3013     state = 0xdeadbee;
3014     action = 0xdeadbee;
3015     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3017     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3018     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3019
3020     state = 0xdeadbee;
3021     action = 0xdeadbee;
3022     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3023     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3024     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3025     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3026
3027     state = 0xdeadbee;
3028     action = 0xdeadbee;
3029     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3030     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3031     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3032     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3033
3034     state = 0xdeadbee;
3035     action = 0xdeadbee;
3036     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3037     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3038     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3039     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3040
3041     state = 0xdeadbee;
3042     action = 0xdeadbee;
3043     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3045     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3046     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3047
3048     state = 0xdeadbee;
3049     action = 0xdeadbee;
3050     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3052     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3053     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3054
3055     state = 0xdeadbee;
3056     action = 0xdeadbee;
3057     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3059     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3060     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3061
3062     state = 0xdeadbee;
3063     action = 0xdeadbee;
3064     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3066     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3067     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3068
3069     state = 0xdeadbee;
3070     action = 0xdeadbee;
3071     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3072     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3073     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3074     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3075
3076     state = 0xdeadbee;
3077     action = 0xdeadbee;
3078     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3079     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3080     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3081     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3082
3083     state = 0xdeadbee;
3084     action = 0xdeadbee;
3085     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3086     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3087     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3088     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3089
3090     state = 0xdeadbee;
3091     action = 0xdeadbee;
3092     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3093     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3094     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3095     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3096
3097     state = 0xdeadbee;
3098     action = 0xdeadbee;
3099     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3101     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3102     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3103
3104     state = 0xdeadbee;
3105     action = 0xdeadbee;
3106     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3108     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3109     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3110
3111     state = 0xdeadbee;
3112     action = 0xdeadbee;
3113     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3115     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3116     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3117
3118     state = 0xdeadbee;
3119     action = 0xdeadbee;
3120     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3122     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3123     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3124
3125     state = 0xdeadbee;
3126     action = 0xdeadbee;
3127     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3129     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3130     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3131
3132     state = 0xdeadbee;
3133     action = 0xdeadbee;
3134     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3136     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3137     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3138
3139     state = 0xdeadbee;
3140     action = 0xdeadbee;
3141     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3143     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3144     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3145
3146     state = 0xdeadbee;
3147     action = 0xdeadbee;
3148     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3150     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3151     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3152
3153     state = 0xdeadbee;
3154     action = 0xdeadbee;
3155     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3157     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3158     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3159
3160     state = 0xdeadbee;
3161     action = 0xdeadbee;
3162     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3164     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3165     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3166
3167     state = 0xdeadbee;
3168     action = 0xdeadbee;
3169     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3171     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3172     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3173
3174     state = 0xdeadbee;
3175     action = 0xdeadbee;
3176     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3177     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3178     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3179     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3180
3181     r = MsiDoAction( hpkg, "CostFinalize");
3182     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3183
3184     state = 0xdeadbee;
3185     action = 0xdeadbee;
3186     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3188     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3189     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3190
3191     state = 0xdeadbee;
3192     action = 0xdeadbee;
3193     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3195     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3196     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3197
3198     state = 0xdeadbee;
3199     action = 0xdeadbee;
3200     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3202     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3203     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3204
3205     state = 0xdeadbee;
3206     action = 0xdeadbee;
3207     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3209     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3210     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3211
3212     state = 0xdeadbee;
3213     action = 0xdeadbee;
3214     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3216     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3217     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3218
3219     state = 0xdeadbee;
3220     action = 0xdeadbee;
3221     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3223     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3224     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3225
3226     state = 0xdeadbee;
3227     action = 0xdeadbee;
3228     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3230     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3231     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3232
3233     state = 0xdeadbee;
3234     action = 0xdeadbee;
3235     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3237     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3238     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3239
3240     state = 0xdeadbee;
3241     action = 0xdeadbee;
3242     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3243     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3244     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3245     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3246
3247     state = 0xdeadbee;
3248     action = 0xdeadbee;
3249     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3250     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3251     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3252     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3253
3254     state = 0xdeadbee;
3255     action = 0xdeadbee;
3256     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3257     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3258     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3259     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3260
3261     state = 0xdeadbee;
3262     action = 0xdeadbee;
3263     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3264     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3265     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3266     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3267
3268     state = 0xdeadbee;
3269     action = 0xdeadbee;
3270     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3271     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3272     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3273     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3274
3275     state = 0xdeadbee;
3276     action = 0xdeadbee;
3277     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3278     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3279     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3280     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3281
3282     state = 0xdeadbee;
3283     action = 0xdeadbee;
3284     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3285     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3286     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3287     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3288
3289     state = 0xdeadbee;
3290     action = 0xdeadbee;
3291     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3292     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3293     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3294     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3295
3296     state = 0xdeadbee;
3297     action = 0xdeadbee;
3298     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3299     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3300     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3301     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3302
3303     state = 0xdeadbee;
3304     action = 0xdeadbee;
3305     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3306     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3307     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3308     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3309
3310     state = 0xdeadbee;
3311     action = 0xdeadbee;
3312     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3313     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3314     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3315     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3316
3317     state = 0xdeadbee;
3318     action = 0xdeadbee;
3319     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3320     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3321     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3322     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3323
3324     state = 0xdeadbee;
3325     action = 0xdeadbee;
3326     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3327     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3328     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3329     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3330
3331     state = 0xdeadbee;
3332     action = 0xdeadbee;
3333     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3334     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3335     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3336     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3337
3338     state = 0xdeadbee;
3339     action = 0xdeadbee;
3340     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3341     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3342     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3343     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3344
3345     state = 0xdeadbee;
3346     action = 0xdeadbee;
3347     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3348     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3349     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3350     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3351
3352     state = 0xdeadbee;
3353     action = 0xdeadbee;
3354     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3355     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3356     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3357     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3358
3359     MsiCloseHandle( hpkg );
3360
3361     /* publish the features and components */
3362     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven");
3363     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3364
3365     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3366     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3367
3368     /* these properties must not be in the saved msi file */
3369     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3370     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3371
3372     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3373     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3374
3375     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3376     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3377
3378     hpkg = package_from_db( hdb );
3379     ok( hpkg, "failed to create package\n");
3380
3381     MsiCloseHandle(hdb);
3382
3383     state = 0xdeadbee;
3384     action = 0xdeadbee;
3385     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3386     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3387     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3388     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3389
3390     state = 0xdeadbee;
3391     action = 0xdeadbee;
3392     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3393     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3394     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3395     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3396
3397     state = 0xdeadbee;
3398     action = 0xdeadbee;
3399     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3400     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3401     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3402     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3403
3404     state = 0xdeadbee;
3405     action = 0xdeadbee;
3406     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3407     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3408     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3409     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3410
3411     state = 0xdeadbee;
3412     action = 0xdeadbee;
3413     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3414     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3415     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3416     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3417
3418     state = 0xdeadbee;
3419     action = 0xdeadbee;
3420     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3421     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3422     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3423     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3424
3425     state = 0xdeadbee;
3426     action = 0xdeadbee;
3427     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3428     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3429     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3430     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3431
3432     state = 0xdeadbee;
3433     action = 0xdeadbee;
3434     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3435     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3436     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3437     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3438
3439     state = 0xdeadbee;
3440     action = 0xdeadbee;
3441     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3442     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3443     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3444     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3445
3446     state = 0xdeadbee;
3447     action = 0xdeadbee;
3448     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3449     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3450     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3451     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3452
3453     state = 0xdeadbee;
3454     action = 0xdeadbee;
3455     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3456     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3457     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3458     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3459
3460     state = 0xdeadbee;
3461     action = 0xdeadbee;
3462     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3463     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3464     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3465     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3466
3467     state = 0xdeadbee;
3468     action = 0xdeadbee;
3469     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3470     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3471     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3472     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3473
3474     state = 0xdeadbee;
3475     action = 0xdeadbee;
3476     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3477     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3478     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3479     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3480
3481     state = 0xdeadbee;
3482     action = 0xdeadbee;
3483     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3484     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3485     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3486     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3487
3488     state = 0xdeadbee;
3489     action = 0xdeadbee;
3490     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3491     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3492     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3493     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3494
3495     state = 0xdeadbee;
3496     action = 0xdeadbee;
3497     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3498     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3499     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3500     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3501
3502     state = 0xdeadbee;
3503     action = 0xdeadbee;
3504     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3505     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3506     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3507     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3508
3509     state = 0xdeadbee;
3510     action = 0xdeadbee;
3511     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3512     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3513     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3514     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3515
3516     state = 0xdeadbee;
3517     action = 0xdeadbee;
3518     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3519     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3520     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3521     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3522
3523     state = 0xdeadbee;
3524     action = 0xdeadbee;
3525     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3526     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3527     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3528     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3529
3530     state = 0xdeadbee;
3531     action = 0xdeadbee;
3532     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3533     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3534     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3535     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3536
3537     state = 0xdeadbee;
3538     action = 0xdeadbee;
3539     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3540     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3541     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3542     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3543
3544     state = 0xdeadbee;
3545     action = 0xdeadbee;
3546     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3547     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3548     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3549     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3550
3551     state = 0xdeadbee;
3552     action = 0xdeadbee;
3553     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3554     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3555     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3556     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3557
3558     r = MsiDoAction( hpkg, "CostInitialize");
3559     ok( r == ERROR_SUCCESS, "cost init failed\n");
3560
3561     state = 0xdeadbee;
3562     action = 0xdeadbee;
3563     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3564     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3565     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3566     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3567
3568     state = 0xdeadbee;
3569     action = 0xdeadbee;
3570     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3571     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3572     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3573     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3574
3575     state = 0xdeadbee;
3576     action = 0xdeadbee;
3577     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3578     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3579     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3580     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3581
3582     state = 0xdeadbee;
3583     action = 0xdeadbee;
3584     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3585     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3586     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3587     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3588
3589     state = 0xdeadbee;
3590     action = 0xdeadbee;
3591     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3592     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3593     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3594     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3595
3596     state = 0xdeadbee;
3597     action = 0xdeadbee;
3598     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3599     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3600     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3601     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3602
3603     state = 0xdeadbee;
3604     action = 0xdeadbee;
3605     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3606     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3607     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3608     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3609
3610     state = 0xdeadbee;
3611     action = 0xdeadbee;
3612     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3613     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3614     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3615     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3616
3617     state = 0xdeadbee;
3618     action = 0xdeadbee;
3619     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3620     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3621     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3622     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3623
3624     state = 0xdeadbee;
3625     action = 0xdeadbee;
3626     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3627     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3628     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3629     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3630
3631     state = 0xdeadbee;
3632     action = 0xdeadbee;
3633     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3635     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3636     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3637
3638     state = 0xdeadbee;
3639     action = 0xdeadbee;
3640     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3641     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3642     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3643     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3644
3645     state = 0xdeadbee;
3646     action = 0xdeadbee;
3647     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3648     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3649     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3650     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3651
3652     state = 0xdeadbee;
3653     action = 0xdeadbee;
3654     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3655     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3656     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3657     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3658
3659     state = 0xdeadbee;
3660     action = 0xdeadbee;
3661     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3663     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3664     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3665
3666     state = 0xdeadbee;
3667     action = 0xdeadbee;
3668     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3669     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3670     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3671     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3672
3673     state = 0xdeadbee;
3674     action = 0xdeadbee;
3675     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3676     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3677     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3678     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3679
3680     state = 0xdeadbee;
3681     action = 0xdeadbee;
3682     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3683     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3684     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3685     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3686
3687     state = 0xdeadbee;
3688     action = 0xdeadbee;
3689     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3690     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3691     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3692     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3693
3694     state = 0xdeadbee;
3695     action = 0xdeadbee;
3696     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3697     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3698     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3699     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3700
3701     state = 0xdeadbee;
3702     action = 0xdeadbee;
3703     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3705     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3706     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3707
3708     state = 0xdeadbee;
3709     action = 0xdeadbee;
3710     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3712     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3713     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3714
3715     state = 0xdeadbee;
3716     action = 0xdeadbee;
3717     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3718     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3719     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3720     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3721
3722     state = 0xdeadbee;
3723     action = 0xdeadbee;
3724     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3725     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3726     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3727     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3728
3729     state = 0xdeadbee;
3730     action = 0xdeadbee;
3731     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3732     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3733     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3734     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3735
3736     r = MsiDoAction( hpkg, "FileCost");
3737     ok( r == ERROR_SUCCESS, "file cost failed\n");
3738
3739     state = 0xdeadbee;
3740     action = 0xdeadbee;
3741     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3742     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3743     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3744     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3745
3746     state = 0xdeadbee;
3747     action = 0xdeadbee;
3748     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3749     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3750     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3751     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3752
3753     state = 0xdeadbee;
3754     action = 0xdeadbee;
3755     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3756     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3757     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3758     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3759
3760     state = 0xdeadbee;
3761     action = 0xdeadbee;
3762     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3763     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3764     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3765     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3766
3767     state = 0xdeadbee;
3768     action = 0xdeadbee;
3769     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3770     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3771     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3772     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3773
3774     state = 0xdeadbee;
3775     action = 0xdeadbee;
3776     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3777     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3778     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3779     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3780
3781     state = 0xdeadbee;
3782     action = 0xdeadbee;
3783     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3784     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3785     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3786     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3787
3788     state = 0xdeadbee;
3789     action = 0xdeadbee;
3790     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3791     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3792     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3793     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3794
3795     state = 0xdeadbee;
3796     action = 0xdeadbee;
3797     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3798     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3799     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3800     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3801
3802     state = 0xdeadbee;
3803     action = 0xdeadbee;
3804     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3805     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3806     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3807     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3808
3809     state = 0xdeadbee;
3810     action = 0xdeadbee;
3811     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3812     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3813     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3814     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3815
3816     state = 0xdeadbee;
3817     action = 0xdeadbee;
3818     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3819     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3820     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3821     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3822
3823     state = 0xdeadbee;
3824     action = 0xdeadbee;
3825     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3826     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3827     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3828     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3829
3830     state = 0xdeadbee;
3831     action = 0xdeadbee;
3832     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3833     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3834     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3835     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3836
3837     state = 0xdeadbee;
3838     action = 0xdeadbee;
3839     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3840     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3841     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3842     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3843
3844     state = 0xdeadbee;
3845     action = 0xdeadbee;
3846     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3847     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3848     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3849     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3850
3851     state = 0xdeadbee;
3852     action = 0xdeadbee;
3853     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3854     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3855     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3856     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3857
3858     state = 0xdeadbee;
3859     action = 0xdeadbee;
3860     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3861     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3862     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3863     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3864
3865     state = 0xdeadbee;
3866     action = 0xdeadbee;
3867     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3868     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3869     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3870     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3871
3872     state = 0xdeadbee;
3873     action = 0xdeadbee;
3874     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3875     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3876     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3877     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3878
3879     state = 0xdeadbee;
3880     action = 0xdeadbee;
3881     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3882     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3883     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3884     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3885
3886     state = 0xdeadbee;
3887     action = 0xdeadbee;
3888     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3889     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3890     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3891     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3892
3893     state = 0xdeadbee;
3894     action = 0xdeadbee;
3895     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3896     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3897     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3898     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3899
3900     state = 0xdeadbee;
3901     action = 0xdeadbee;
3902     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3903     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3904     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3905     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3906
3907     state = 0xdeadbee;
3908     action = 0xdeadbee;
3909     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3910     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3911     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3912     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3913
3914     r = MsiDoAction( hpkg, "CostFinalize");
3915     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3916
3917     state = 0xdeadbee;
3918     action = 0xdeadbee;
3919     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3920     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3921     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3922     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3923
3924     state = 0xdeadbee;
3925     action = 0xdeadbee;
3926     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3927     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3928     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3929     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3930
3931     state = 0xdeadbee;
3932     action = 0xdeadbee;
3933     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3934     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3935     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3936     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3937
3938     state = 0xdeadbee;
3939     action = 0xdeadbee;
3940     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3941     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3942     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3943     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3944
3945     state = 0xdeadbee;
3946     action = 0xdeadbee;
3947     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3948     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3949     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3950     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3951
3952     state = 0xdeadbee;
3953     action = 0xdeadbee;
3954     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3955     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3956     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3957     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3958
3959     state = 0xdeadbee;
3960     action = 0xdeadbee;
3961     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3962     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3963     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3964     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3965
3966     state = 0xdeadbee;
3967     action = 0xdeadbee;
3968     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3969     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3970     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3971     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3972
3973     state = 0xdeadbee;
3974     action = 0xdeadbee;
3975     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3976     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3977     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3978     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3979
3980     state = 0xdeadbee;
3981     action = 0xdeadbee;
3982     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3983     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3984     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3985     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3986
3987     state = 0xdeadbee;
3988     action = 0xdeadbee;
3989     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3990     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3991     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3992     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3993
3994     state = 0xdeadbee;
3995     action = 0xdeadbee;
3996     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3997     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3998     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3999     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4000
4001     state = 0xdeadbee;
4002     action = 0xdeadbee;
4003     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4004     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4005     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4006     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4007
4008     state = 0xdeadbee;
4009     action = 0xdeadbee;
4010     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4011     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4012     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4013     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4014
4015     state = 0xdeadbee;
4016     action = 0xdeadbee;
4017     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4018     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4019     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4020     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4021
4022     state = 0xdeadbee;
4023     action = 0xdeadbee;
4024     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4025     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4026     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4027     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4028
4029     state = 0xdeadbee;
4030     action = 0xdeadbee;
4031     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4032     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4033     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4034     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4035
4036     state = 0xdeadbee;
4037     action = 0xdeadbee;
4038     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4039     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4040     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4041     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4042
4043     state = 0xdeadbee;
4044     action = 0xdeadbee;
4045     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4046     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4047     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4048     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4049
4050     state = 0xdeadbee;
4051     action = 0xdeadbee;
4052     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4053     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4054     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4055     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4056
4057     state = 0xdeadbee;
4058     action = 0xdeadbee;
4059     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4060     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4061     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4062     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4063
4064     state = 0xdeadbee;
4065     action = 0xdeadbee;
4066     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4067     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4068     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4069     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4070
4071     state = 0xdeadbee;
4072     action = 0xdeadbee;
4073     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4074     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4075     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4076     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4077
4078     state = 0xdeadbee;
4079     action = 0xdeadbee;
4080     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4081     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4082     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4083     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4084
4085     state = 0xdeadbee;
4086     action = 0xdeadbee;
4087     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4088     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4089     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4090     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4091
4092     MsiCloseHandle(hpkg);
4093
4094     /* uninstall the product */
4095     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4096     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4097
4098     /* all features installed locally */
4099     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4100     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4101
4102     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4103     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4104
4105     /* these properties must not be in the saved msi file */
4106     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven'");
4107     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4108
4109     hpkg = package_from_db( hdb );
4110     ok( hpkg, "failed to create package\n");
4111
4112     state = 0xdeadbee;
4113     action = 0xdeadbee;
4114     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4115     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4116     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4117     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4118
4119     state = 0xdeadbee;
4120     action = 0xdeadbee;
4121     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4122     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4123     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4124     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4125
4126     state = 0xdeadbee;
4127     action = 0xdeadbee;
4128     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4129     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4130     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4131     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4132
4133     state = 0xdeadbee;
4134     action = 0xdeadbee;
4135     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4136     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4137     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4138     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4139
4140     state = 0xdeadbee;
4141     action = 0xdeadbee;
4142     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4143     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4144     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4145     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4146
4147     state = 0xdeadbee;
4148     action = 0xdeadbee;
4149     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4150     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4151     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4152     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4153
4154     state = 0xdeadbee;
4155     action = 0xdeadbee;
4156     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4157     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4158     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4159     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4160
4161     state = 0xdeadbee;
4162     action = 0xdeadbee;
4163     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4164     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4165     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4166     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4167
4168     state = 0xdeadbee;
4169     action = 0xdeadbee;
4170     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4171     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4172     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4173     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4174
4175     state = 0xdeadbee;
4176     action = 0xdeadbee;
4177     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4178     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4179     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4180     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4181
4182     state = 0xdeadbee;
4183     action = 0xdeadbee;
4184     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4185     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4186     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4187     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4188
4189     state = 0xdeadbee;
4190     action = 0xdeadbee;
4191     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4192     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4193     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4194     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4195
4196     state = 0xdeadbee;
4197     action = 0xdeadbee;
4198     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4199     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4200     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4201     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4202
4203     state = 0xdeadbee;
4204     action = 0xdeadbee;
4205     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4206     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4207     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4208     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4209
4210     state = 0xdeadbee;
4211     action = 0xdeadbee;
4212     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4213     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4214     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4215     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4216
4217     state = 0xdeadbee;
4218     action = 0xdeadbee;
4219     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4220     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4221     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4222     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4223
4224     state = 0xdeadbee;
4225     action = 0xdeadbee;
4226     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4227     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4228     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4229     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4230
4231     state = 0xdeadbee;
4232     action = 0xdeadbee;
4233     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4234     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4235     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4236     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4237
4238     state = 0xdeadbee;
4239     action = 0xdeadbee;
4240     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4241     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4242     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4243     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4244
4245     state = 0xdeadbee;
4246     action = 0xdeadbee;
4247     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4248     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4249     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4250     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4251
4252     state = 0xdeadbee;
4253     action = 0xdeadbee;
4254     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4255     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4256     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4257     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4258
4259     state = 0xdeadbee;
4260     action = 0xdeadbee;
4261     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4262     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4263     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4264     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4265
4266     state = 0xdeadbee;
4267     action = 0xdeadbee;
4268     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4269     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4270     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4271     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4272
4273     state = 0xdeadbee;
4274     action = 0xdeadbee;
4275     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4276     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4277     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4278     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4279
4280     state = 0xdeadbee;
4281     action = 0xdeadbee;
4282     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4283     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4284     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4285     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4286
4287     r = MsiDoAction( hpkg, "CostInitialize");
4288     ok( r == ERROR_SUCCESS, "cost init failed\n");
4289
4290     state = 0xdeadbee;
4291     action = 0xdeadbee;
4292     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4293     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4294     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4295     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4296
4297     state = 0xdeadbee;
4298     action = 0xdeadbee;
4299     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4300     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4301     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4302     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4303
4304     state = 0xdeadbee;
4305     action = 0xdeadbee;
4306     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4307     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4308     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4309     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4310
4311     state = 0xdeadbee;
4312     action = 0xdeadbee;
4313     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4314     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4315     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4316     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4317
4318     state = 0xdeadbee;
4319     action = 0xdeadbee;
4320     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4321     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4322     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4323     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4324
4325     state = 0xdeadbee;
4326     action = 0xdeadbee;
4327     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4328     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4329     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4330     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4331
4332     state = 0xdeadbee;
4333     action = 0xdeadbee;
4334     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4335     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4336     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4337     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4338
4339     state = 0xdeadbee;
4340     action = 0xdeadbee;
4341     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4342     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4343     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4344     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4345
4346     state = 0xdeadbee;
4347     action = 0xdeadbee;
4348     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4349     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4350     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4351     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4352
4353     state = 0xdeadbee;
4354     action = 0xdeadbee;
4355     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4356     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4357     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4358     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4359
4360     state = 0xdeadbee;
4361     action = 0xdeadbee;
4362     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4363     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4364     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4365     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4366
4367     state = 0xdeadbee;
4368     action = 0xdeadbee;
4369     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4370     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4371     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4372     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4373
4374     state = 0xdeadbee;
4375     action = 0xdeadbee;
4376     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4377     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4378     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4379     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4380
4381     state = 0xdeadbee;
4382     action = 0xdeadbee;
4383     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4384     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4385     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4386     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4387
4388     state = 0xdeadbee;
4389     action = 0xdeadbee;
4390     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4391     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4392     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4393     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4394
4395     state = 0xdeadbee;
4396     action = 0xdeadbee;
4397     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4398     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4399     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4400     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4401
4402     state = 0xdeadbee;
4403     action = 0xdeadbee;
4404     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4405     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4406     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4407     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4408
4409     state = 0xdeadbee;
4410     action = 0xdeadbee;
4411     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4412     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4413     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4414     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4415
4416     state = 0xdeadbee;
4417     action = 0xdeadbee;
4418     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4419     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4420     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4421     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4422
4423     state = 0xdeadbee;
4424     action = 0xdeadbee;
4425     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4426     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4427     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4428     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4429
4430     state = 0xdeadbee;
4431     action = 0xdeadbee;
4432     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4433     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4434     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4435     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4436
4437     state = 0xdeadbee;
4438     action = 0xdeadbee;
4439     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4440     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4441     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4442     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4443
4444     state = 0xdeadbee;
4445     action = 0xdeadbee;
4446     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4448     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4449     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4450
4451     state = 0xdeadbee;
4452     action = 0xdeadbee;
4453     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4455     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4456     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4457
4458     state = 0xdeadbee;
4459     action = 0xdeadbee;
4460     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4461     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4462     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4463     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4464
4465     r = MsiDoAction( hpkg, "FileCost");
4466     ok( r == ERROR_SUCCESS, "file cost failed\n");
4467
4468     state = 0xdeadbee;
4469     action = 0xdeadbee;
4470     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4471     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4472     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4473     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4474
4475     state = 0xdeadbee;
4476     action = 0xdeadbee;
4477     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4478     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4479     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4480     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4481
4482     state = 0xdeadbee;
4483     action = 0xdeadbee;
4484     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4485     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4486     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4487     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4488
4489     state = 0xdeadbee;
4490     action = 0xdeadbee;
4491     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4492     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4493     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4494     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4495
4496     state = 0xdeadbee;
4497     action = 0xdeadbee;
4498     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4499     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4500     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4501     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4502
4503     state = 0xdeadbee;
4504     action = 0xdeadbee;
4505     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4506     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4507     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4508     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4509
4510     state = 0xdeadbee;
4511     action = 0xdeadbee;
4512     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4513     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4514     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4515     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4516
4517     state = 0xdeadbee;
4518     action = 0xdeadbee;
4519     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4520     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4521     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4522     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4523
4524     state = 0xdeadbee;
4525     action = 0xdeadbee;
4526     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4527     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4528     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4529     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4530
4531     state = 0xdeadbee;
4532     action = 0xdeadbee;
4533     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4534     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4535     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4536     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4537
4538     state = 0xdeadbee;
4539     action = 0xdeadbee;
4540     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4541     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4542     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4543     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4544
4545     state = 0xdeadbee;
4546     action = 0xdeadbee;
4547     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4548     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4549     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4550     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4551
4552     state = 0xdeadbee;
4553     action = 0xdeadbee;
4554     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4555     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4556     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4557     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4558
4559     state = 0xdeadbee;
4560     action = 0xdeadbee;
4561     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4562     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4563     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4564     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4565
4566     state = 0xdeadbee;
4567     action = 0xdeadbee;
4568     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4569     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4570     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4571     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4572
4573     state = 0xdeadbee;
4574     action = 0xdeadbee;
4575     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4576     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4577     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4578     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4579
4580     state = 0xdeadbee;
4581     action = 0xdeadbee;
4582     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4583     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4584     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4585     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4586
4587     state = 0xdeadbee;
4588     action = 0xdeadbee;
4589     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4590     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4591     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4592     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4593
4594     state = 0xdeadbee;
4595     action = 0xdeadbee;
4596     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4597     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4598     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4599     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4600
4601     state = 0xdeadbee;
4602     action = 0xdeadbee;
4603     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4604     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4605     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4606     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4607
4608     state = 0xdeadbee;
4609     action = 0xdeadbee;
4610     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4611     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4612     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4613     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4614
4615     state = 0xdeadbee;
4616     action = 0xdeadbee;
4617     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4618     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4619     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4620     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4621
4622     state = 0xdeadbee;
4623     action = 0xdeadbee;
4624     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4625     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4626     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4627     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4628
4629     state = 0xdeadbee;
4630     action = 0xdeadbee;
4631     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4632     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4633     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4634     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4635
4636     state = 0xdeadbee;
4637     action = 0xdeadbee;
4638     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4639     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4640     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4641     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4642
4643     r = MsiDoAction( hpkg, "CostFinalize");
4644     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4645
4646     state = 0xdeadbee;
4647     action = 0xdeadbee;
4648     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4649     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4650     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4651     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4652
4653     state = 0xdeadbee;
4654     action = 0xdeadbee;
4655     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4656     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4657     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4658     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4659
4660     state = 0xdeadbee;
4661     action = 0xdeadbee;
4662     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4663     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4664     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4665     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4666
4667     state = 0xdeadbee;
4668     action = 0xdeadbee;
4669     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4670     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4671     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4672     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4673
4674     state = 0xdeadbee;
4675     action = 0xdeadbee;
4676     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4677     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4678     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4679     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4680
4681     state = 0xdeadbee;
4682     action = 0xdeadbee;
4683     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4684     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4685     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4686     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4687
4688     state = 0xdeadbee;
4689     action = 0xdeadbee;
4690     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4691     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4692     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4693     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4694
4695     state = 0xdeadbee;
4696     action = 0xdeadbee;
4697     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4698     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4699     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4700     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4701
4702     state = 0xdeadbee;
4703     action = 0xdeadbee;
4704     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4705     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4706     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4707     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4708
4709     state = 0xdeadbee;
4710     action = 0xdeadbee;
4711     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4712     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4713     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4714     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4715
4716     state = 0xdeadbee;
4717     action = 0xdeadbee;
4718     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4719     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4720     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4721     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4722
4723     state = 0xdeadbee;
4724     action = 0xdeadbee;
4725     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4726     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4727     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4728     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4729
4730     state = 0xdeadbee;
4731     action = 0xdeadbee;
4732     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4733     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4734     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4735     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4736
4737     state = 0xdeadbee;
4738     action = 0xdeadbee;
4739     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4740     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4741     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4742     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4743
4744     state = 0xdeadbee;
4745     action = 0xdeadbee;
4746     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4747     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4748     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4749     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4750
4751     state = 0xdeadbee;
4752     action = 0xdeadbee;
4753     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4754     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4755     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4756     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4757
4758     state = 0xdeadbee;
4759     action = 0xdeadbee;
4760     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4761     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4762     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4763     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4764
4765     state = 0xdeadbee;
4766     action = 0xdeadbee;
4767     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4768     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4769     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4770     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4771
4772     state = 0xdeadbee;
4773     action = 0xdeadbee;
4774     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4775     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4776     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4777     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4778
4779     state = 0xdeadbee;
4780     action = 0xdeadbee;
4781     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4782     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4783     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4784     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4785
4786     state = 0xdeadbee;
4787     action = 0xdeadbee;
4788     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4789     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4790     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4791     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4792
4793     state = 0xdeadbee;
4794     action = 0xdeadbee;
4795     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4796     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4797     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4798     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4799
4800     state = 0xdeadbee;
4801     action = 0xdeadbee;
4802     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4803     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4804     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4805     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4806
4807     state = 0xdeadbee;
4808     action = 0xdeadbee;
4809     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4810     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4811     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4812     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4813
4814     state = 0xdeadbee;
4815     action = 0xdeadbee;
4816     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4817     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4818     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4819     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4820
4821     MsiCloseHandle(hpkg);
4822
4823     /* uninstall the product */
4824     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
4825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4826
4827     /* all features installed from source */
4828     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
4829     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4830
4831     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
4832     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4833
4834     /* this property must not be in the saved msi file */
4835     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven'");
4836     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4837
4838     hpkg = package_from_db( hdb );
4839     ok( hpkg, "failed to create package\n");
4840
4841     state = 0xdeadbee;
4842     action = 0xdeadbee;
4843     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4844     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4845     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4846     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4847
4848     state = 0xdeadbee;
4849     action = 0xdeadbee;
4850     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4851     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4852     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4853     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4854
4855     state = 0xdeadbee;
4856     action = 0xdeadbee;
4857     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4858     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4859     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4860     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4861
4862     state = 0xdeadbee;
4863     action = 0xdeadbee;
4864     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4865     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4866     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4867     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4868
4869     state = 0xdeadbee;
4870     action = 0xdeadbee;
4871     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4872     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4873     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4874     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4875
4876     state = 0xdeadbee;
4877     action = 0xdeadbee;
4878     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4879     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4880     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4881     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4882
4883     state = 0xdeadbee;
4884     action = 0xdeadbee;
4885     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4886     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4887     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4888     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4889
4890     state = 0xdeadbee;
4891     action = 0xdeadbee;
4892     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4893     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4894     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4895     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4896
4897     state = 0xdeadbee;
4898     action = 0xdeadbee;
4899     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4900     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4901     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4902     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4903
4904     state = 0xdeadbee;
4905     action = 0xdeadbee;
4906     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4907     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4908     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4909     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4910
4911     state = 0xdeadbee;
4912     action = 0xdeadbee;
4913     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4914     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4915     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4916     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4917
4918     state = 0xdeadbee;
4919     action = 0xdeadbee;
4920     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4921     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4922     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4923     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4924
4925     state = 0xdeadbee;
4926     action = 0xdeadbee;
4927     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4928     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4929     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4930     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4931
4932     state = 0xdeadbee;
4933     action = 0xdeadbee;
4934     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4935     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4936     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4937     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4938
4939     state = 0xdeadbee;
4940     action = 0xdeadbee;
4941     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4942     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4943     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4944     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4945
4946     state = 0xdeadbee;
4947     action = 0xdeadbee;
4948     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4949     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4950     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4951     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4952
4953     state = 0xdeadbee;
4954     action = 0xdeadbee;
4955     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4956     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4957     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4958     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4959
4960     state = 0xdeadbee;
4961     action = 0xdeadbee;
4962     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4963     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4964     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4965     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4966
4967     state = 0xdeadbee;
4968     action = 0xdeadbee;
4969     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4970     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4971     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4972     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4973
4974     state = 0xdeadbee;
4975     action = 0xdeadbee;
4976     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4977     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4978     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4979     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4980
4981     state = 0xdeadbee;
4982     action = 0xdeadbee;
4983     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4984     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4985     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4986     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4987
4988     state = 0xdeadbee;
4989     action = 0xdeadbee;
4990     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4991     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4992     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4993     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4994
4995     state = 0xdeadbee;
4996     action = 0xdeadbee;
4997     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4998     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4999     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5000     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5001
5002     state = 0xdeadbee;
5003     action = 0xdeadbee;
5004     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5005     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5006     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5007     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5008
5009     state = 0xdeadbee;
5010     action = 0xdeadbee;
5011     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5012     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5013     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5014     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5015
5016     r = MsiDoAction( hpkg, "CostInitialize");
5017     ok( r == ERROR_SUCCESS, "cost init failed\n");
5018
5019     state = 0xdeadbee;
5020     action = 0xdeadbee;
5021     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5022     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5023     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5024     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5025
5026     state = 0xdeadbee;
5027     action = 0xdeadbee;
5028     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5029     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5030     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5031     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5032
5033     state = 0xdeadbee;
5034     action = 0xdeadbee;
5035     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5036     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5037     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5038     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5039
5040     state = 0xdeadbee;
5041     action = 0xdeadbee;
5042     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5043     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5044     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5045     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5046
5047     state = 0xdeadbee;
5048     action = 0xdeadbee;
5049     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5050     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5051     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5052     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5053
5054     state = 0xdeadbee;
5055     action = 0xdeadbee;
5056     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5057     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5058     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5059     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5060
5061     state = 0xdeadbee;
5062     action = 0xdeadbee;
5063     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5064     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5065     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5066     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5067
5068     state = 0xdeadbee;
5069     action = 0xdeadbee;
5070     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5071     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5072     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5073     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5074
5075     state = 0xdeadbee;
5076     action = 0xdeadbee;
5077     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5079     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5080     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5081
5082     state = 0xdeadbee;
5083     action = 0xdeadbee;
5084     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5086     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5087     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5088
5089     state = 0xdeadbee;
5090     action = 0xdeadbee;
5091     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5093     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5094     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5095
5096     state = 0xdeadbee;
5097     action = 0xdeadbee;
5098     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5100     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5101     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5102
5103     state = 0xdeadbee;
5104     action = 0xdeadbee;
5105     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5107     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5108     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5109
5110     state = 0xdeadbee;
5111     action = 0xdeadbee;
5112     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5114     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5115     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5116
5117     state = 0xdeadbee;
5118     action = 0xdeadbee;
5119     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5121     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5122     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5123
5124     state = 0xdeadbee;
5125     action = 0xdeadbee;
5126     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5128     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5129     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5130
5131     state = 0xdeadbee;
5132     action = 0xdeadbee;
5133     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5135     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5136     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5137
5138     state = 0xdeadbee;
5139     action = 0xdeadbee;
5140     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5142     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5143     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5144
5145     state = 0xdeadbee;
5146     action = 0xdeadbee;
5147     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5149     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5150     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5151
5152     state = 0xdeadbee;
5153     action = 0xdeadbee;
5154     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5156     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5157     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5158
5159     state = 0xdeadbee;
5160     action = 0xdeadbee;
5161     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5163     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5164     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5165
5166     state = 0xdeadbee;
5167     action = 0xdeadbee;
5168     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5170     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5171     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5172
5173     state = 0xdeadbee;
5174     action = 0xdeadbee;
5175     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5177     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5178     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5179
5180     state = 0xdeadbee;
5181     action = 0xdeadbee;
5182     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5184     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5185     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5186
5187     state = 0xdeadbee;
5188     action = 0xdeadbee;
5189     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5191     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5192     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5193
5194     r = MsiDoAction( hpkg, "FileCost");
5195     ok( r == ERROR_SUCCESS, "file cost failed\n");
5196
5197     state = 0xdeadbee;
5198     action = 0xdeadbee;
5199     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5201     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5202     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5203
5204     state = 0xdeadbee;
5205     action = 0xdeadbee;
5206     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5208     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5209     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5210
5211     state = 0xdeadbee;
5212     action = 0xdeadbee;
5213     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5215     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5216     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5217
5218     state = 0xdeadbee;
5219     action = 0xdeadbee;
5220     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5222     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5223     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5224
5225     state = 0xdeadbee;
5226     action = 0xdeadbee;
5227     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5228     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5229     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5230     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5231
5232     state = 0xdeadbee;
5233     action = 0xdeadbee;
5234     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5235     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5236     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5237     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5238
5239     state = 0xdeadbee;
5240     action = 0xdeadbee;
5241     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5243     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5244     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5245
5246     state = 0xdeadbee;
5247     action = 0xdeadbee;
5248     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5249     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5250     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5251     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5252
5253     state = 0xdeadbee;
5254     action = 0xdeadbee;
5255     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5256     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5257     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5258     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5259
5260     state = 0xdeadbee;
5261     action = 0xdeadbee;
5262     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5263     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5264     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5265     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5266
5267     state = 0xdeadbee;
5268     action = 0xdeadbee;
5269     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5270     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5271     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5272     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5273
5274     state = 0xdeadbee;
5275     action = 0xdeadbee;
5276     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5277     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5278     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5279     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5280
5281     state = 0xdeadbee;
5282     action = 0xdeadbee;
5283     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5284     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5285     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5286     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5287
5288     state = 0xdeadbee;
5289     action = 0xdeadbee;
5290     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5291     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5292     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5293     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5294
5295     state = 0xdeadbee;
5296     action = 0xdeadbee;
5297     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5298     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5299     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5300     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5301
5302     state = 0xdeadbee;
5303     action = 0xdeadbee;
5304     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5305     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5306     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5307     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5308
5309     state = 0xdeadbee;
5310     action = 0xdeadbee;
5311     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5312     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5313     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5314     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5315
5316     state = 0xdeadbee;
5317     action = 0xdeadbee;
5318     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5319     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5320     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5321     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5322
5323     state = 0xdeadbee;
5324     action = 0xdeadbee;
5325     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5326     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5327     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5328     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5329
5330     state = 0xdeadbee;
5331     action = 0xdeadbee;
5332     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5333     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5334     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5335     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5336
5337     state = 0xdeadbee;
5338     action = 0xdeadbee;
5339     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5340     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5341     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5342     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5343
5344     state = 0xdeadbee;
5345     action = 0xdeadbee;
5346     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5347     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5348     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5349     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5350
5351     state = 0xdeadbee;
5352     action = 0xdeadbee;
5353     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5354     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5355     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5356     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5357
5358     state = 0xdeadbee;
5359     action = 0xdeadbee;
5360     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5361     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5362     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5363     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5364
5365     state = 0xdeadbee;
5366     action = 0xdeadbee;
5367     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5368     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5369     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5370     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5371
5372     r = MsiDoAction( hpkg, "CostFinalize");
5373     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5374
5375     state = 0xdeadbee;
5376     action = 0xdeadbee;
5377     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5378     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5379     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5380     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5381
5382     state = 0xdeadbee;
5383     action = 0xdeadbee;
5384     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5385     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5386     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5387     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5388
5389     state = 0xdeadbee;
5390     action = 0xdeadbee;
5391     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5392     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5393     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5394     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5395
5396     state = 0xdeadbee;
5397     action = 0xdeadbee;
5398     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5399     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5400     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5401     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5402
5403     state = 0xdeadbee;
5404     action = 0xdeadbee;
5405     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5406     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5407     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5408     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5409
5410     state = 0xdeadbee;
5411     action = 0xdeadbee;
5412     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5413     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5414     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5415     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5416
5417     state = 0xdeadbee;
5418     action = 0xdeadbee;
5419     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5420     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5421     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5422     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5423
5424     state = 0xdeadbee;
5425     action = 0xdeadbee;
5426     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5427     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5428     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5429     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5430
5431     state = 0xdeadbee;
5432     action = 0xdeadbee;
5433     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5434     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5435     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5436     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5437
5438     state = 0xdeadbee;
5439     action = 0xdeadbee;
5440     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5441     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5442     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5443     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5444
5445     state = 0xdeadbee;
5446     action = 0xdeadbee;
5447     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5448     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5449     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5450     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5451
5452     state = 0xdeadbee;
5453     action = 0xdeadbee;
5454     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5455     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5456     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5457     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5458
5459     state = 0xdeadbee;
5460     action = 0xdeadbee;
5461     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5462     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5463     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5464     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5465
5466     state = 0xdeadbee;
5467     action = 0xdeadbee;
5468     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5469     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5470     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5471     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5472
5473     state = 0xdeadbee;
5474     action = 0xdeadbee;
5475     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5476     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5477     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5478     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5479
5480     state = 0xdeadbee;
5481     action = 0xdeadbee;
5482     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5483     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5484     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5485     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5486
5487     state = 0xdeadbee;
5488     action = 0xdeadbee;
5489     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5490     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5491     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5492     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5493
5494     state = 0xdeadbee;
5495     action = 0xdeadbee;
5496     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5497     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5498     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5499     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5500
5501     state = 0xdeadbee;
5502     action = 0xdeadbee;
5503     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5504     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5505     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5506     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5507
5508     state = 0xdeadbee;
5509     action = 0xdeadbee;
5510     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5511     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5512     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5513     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5514
5515     state = 0xdeadbee;
5516     action = 0xdeadbee;
5517     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5518     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5519     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5520     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5521
5522     state = 0xdeadbee;
5523     action = 0xdeadbee;
5524     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5525     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5526     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5527     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5528
5529     state = 0xdeadbee;
5530     action = 0xdeadbee;
5531     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5532     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5533     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5534     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5535
5536     state = 0xdeadbee;
5537     action = 0xdeadbee;
5538     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5539     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5540     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5541     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5542
5543     state = 0xdeadbee;
5544     action = 0xdeadbee;
5545     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5546     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5547     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5548     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5549
5550     MsiCloseHandle(hpkg);
5551
5552     /* uninstall the product */
5553     r = MsiInstallProduct(msifile3, "REMOVE=ALL");
5554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5555
5556     DeleteFileA(msifile);
5557     DeleteFileA(msifile2);
5558     DeleteFileA(msifile3);
5559 }
5560
5561 static void test_getproperty(void)
5562 {
5563     MSIHANDLE hPackage = 0;
5564     char prop[100];
5565     static CHAR empty[] = "";
5566     DWORD size;
5567     UINT r;
5568
5569     hPackage = package_from_db(create_package_db());
5570     ok( hPackage != 0, " Failed to create package\n");
5571
5572     /* set the property */
5573     r = MsiSetProperty(hPackage, "Name", "Value");
5574     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5575
5576     /* retrieve the size, NULL pointer */
5577     size = 0;
5578     r = MsiGetProperty(hPackage, "Name", NULL, &size);
5579     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5580     ok( size == 5, "Expected 5, got %d\n", size);
5581
5582     /* retrieve the size, empty string */
5583     size = 0;
5584     r = MsiGetProperty(hPackage, "Name", empty, &size);
5585     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
5586     ok( size == 5, "Expected 5, got %d\n", size);
5587
5588     /* don't change size */
5589     r = MsiGetProperty(hPackage, "Name", prop, &size);
5590     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
5591     ok( size == 5, "Expected 5, got %d\n", size);
5592     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
5593
5594     /* increase the size by 1 */
5595     size++;
5596     r = MsiGetProperty(hPackage, "Name", prop, &size);
5597     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5598     ok( size == 5, "Expected 5, got %d\n", size);
5599     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
5600
5601     r = MsiCloseHandle( hPackage);
5602     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
5603     DeleteFile(msifile);
5604 }
5605
5606 static void test_removefiles(void)
5607 {
5608     MSIHANDLE hpkg;
5609     UINT r;
5610     MSIHANDLE hdb;
5611
5612     hdb = create_package_db();
5613     ok ( hdb, "failed to create package database\n" );
5614
5615     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5616     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5617
5618     r = create_feature_table( hdb );
5619     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5620
5621     r = create_component_table( hdb );
5622     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5623
5624     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
5625     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5626
5627     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
5628     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5629
5630     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
5631     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5632
5633     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
5634     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5635
5636     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
5637     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5638
5639     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
5640     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5641
5642     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
5643     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5644
5645     r = create_feature_components_table( hdb );
5646     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5647
5648     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
5649     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5650
5651     r = add_feature_components_entry( hdb, "'one', 'helium'" );
5652     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5653
5654     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
5655     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5656
5657     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
5658     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5659
5660     r = add_feature_components_entry( hdb, "'one', 'boron'" );
5661     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5662
5663     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
5664     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5665
5666     r = create_file_table( hdb );
5667     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5668
5669     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
5670     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5671
5672     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
5673     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5674
5675     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
5676     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5677
5678     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
5679     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5680
5681     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
5682     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5683
5684     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
5685     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5686
5687     r = create_remove_file_table( hdb );
5688     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
5689
5690     hpkg = package_from_db( hdb );
5691     ok( hpkg, "failed to create package\n");
5692
5693     MsiCloseHandle( hdb );
5694
5695     create_test_file( "hydrogen.txt" );
5696     create_test_file( "helium.txt" );
5697     create_test_file( "lithium.txt" );
5698     create_test_file( "beryllium.txt" );
5699     create_test_file( "boron.txt" );
5700     create_test_file( "carbon.txt" );
5701
5702     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
5703     ok( r == ERROR_SUCCESS, "set property failed\n");
5704
5705     r = MsiDoAction( hpkg, "CostInitialize");
5706     ok( r == ERROR_SUCCESS, "cost init failed\n");
5707
5708     r = MsiDoAction( hpkg, "FileCost");
5709     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5710
5711     r = MsiDoAction( hpkg, "CostFinalize");
5712     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5713
5714     r = MsiDoAction( hpkg, "InstallValidate");
5715     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5716
5717     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
5718     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5719
5720     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
5721     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5722
5723     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
5724     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5725
5726     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
5727     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5728
5729     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
5730     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5731
5732     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
5733     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5734
5735     r = MsiDoAction( hpkg, "RemoveFiles");
5736     ok( r == ERROR_SUCCESS, "remove files failed\n");
5737
5738     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
5739     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
5740     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
5741     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
5742     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
5743     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
5744
5745     MsiCloseHandle( hpkg );
5746     DeleteFileA(msifile);
5747 }
5748
5749 static void test_appsearch(void)
5750 {
5751     MSIHANDLE hpkg;
5752     UINT r;
5753     MSIHANDLE hdb;
5754     CHAR prop[MAX_PATH];
5755     DWORD size = MAX_PATH;
5756
5757     hdb = create_package_db();
5758     ok ( hdb, "failed to create package database\n" );
5759
5760     r = create_appsearch_table( hdb );
5761     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
5762
5763     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
5764     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
5765
5766     r = create_reglocator_table( hdb );
5767     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
5768
5769     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
5770     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
5771
5772     r = create_signature_table( hdb );
5773     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
5774
5775     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
5776     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
5777
5778     hpkg = package_from_db( hdb );
5779     ok( hpkg, "failed to create package\n");
5780
5781     MsiCloseHandle( hdb );
5782
5783     r = MsiDoAction( hpkg, "AppSearch" );
5784     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
5785
5786     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
5787     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
5788     ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
5789
5790     MsiCloseHandle( hpkg );
5791     DeleteFileA(msifile);
5792 }
5793
5794 static void test_appsearch_complocator(void)
5795 {
5796     MSIHANDLE hpkg, hdb;
5797     CHAR path[MAX_PATH];
5798     CHAR prop[MAX_PATH];
5799     LPSTR usersid;
5800     DWORD size;
5801     UINT r;
5802
5803     get_user_sid(&usersid);
5804     if (!usersid)
5805     {
5806         skip("ConvertSidToStringSidA is not available\n");
5807         return;
5808     }
5809
5810     create_test_file("FileName1");
5811     create_test_file("FileName4");
5812     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
5813                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
5814
5815     create_test_file("FileName2");
5816     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
5817                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
5818
5819     create_test_file("FileName3");
5820     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
5821                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
5822
5823     create_test_file("FileName5");
5824     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
5825                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
5826
5827     create_test_file("FileName6");
5828     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
5829                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
5830
5831     create_test_file("FileName7");
5832     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
5833                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
5834
5835     /* dir is FALSE, but we're pretending it's a directory */
5836     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
5837                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
5838
5839     hdb = create_package_db();
5840     ok(hdb, "Expected a valid database handle\n");
5841
5842     r = create_appsearch_table(hdb);
5843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5844
5845     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5846     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5847
5848     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5849     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5850
5851     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5853
5854     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5856
5857     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5859
5860     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5862
5863     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5865
5866     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5868
5869     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5871
5872     r = create_complocator_table(hdb);
5873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5874
5875     /* published component, machine, file, signature, misdbLocatorTypeFile */
5876     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
5877     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5878
5879     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
5880     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
5881     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5882
5883     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
5884     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
5885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5886
5887     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
5888     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
5889     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5890
5891     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
5892     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
5893     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5894
5895     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
5896     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
5897     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5898
5899     /* published component, machine, file, no signature, misdbLocatorTypeFile */
5900     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
5901     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5902
5903     /* unpublished component, no signature, misdbLocatorTypeDir */
5904     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
5905     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5906
5907     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
5908     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
5909     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5910
5911     r = create_signature_table(hdb);
5912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5913
5914     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
5915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5916
5917     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
5918     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5919
5920     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
5921     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5922
5923     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
5924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5925
5926     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
5927     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5928
5929     hpkg = package_from_db(hdb);
5930     ok(hpkg, "Expected a valid package handle\n");
5931
5932     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
5933     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5934
5935     r = MsiDoAction(hpkg, "AppSearch");
5936     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5937
5938     size = MAX_PATH;
5939     sprintf(path, "%s\\FileName1", CURR_DIR);
5940     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5941     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5942     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5943
5944     size = MAX_PATH;
5945     sprintf(path, "%s\\FileName2", CURR_DIR);
5946     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5947     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5948     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5949
5950     size = MAX_PATH;
5951     sprintf(path, "%s\\FileName3", CURR_DIR);
5952     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5953     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5954     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5955
5956     size = MAX_PATH;
5957     sprintf(path, "%s\\FileName4", CURR_DIR);
5958     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5959     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5960     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5961
5962     size = MAX_PATH;
5963     sprintf(path, "%s\\FileName5", CURR_DIR);
5964     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5965     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5966     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5967
5968     size = MAX_PATH;
5969     sprintf(path, "%s\\", CURR_DIR);
5970     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5971     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5972     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5973
5974     size = MAX_PATH;
5975     sprintf(path, "%s\\", CURR_DIR);
5976     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5977     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5978     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5979
5980     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5981     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5982     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
5983
5984     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5985     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5986     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5987
5988     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
5989                           MSIINSTALLCONTEXT_MACHINE, NULL);
5990     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
5991                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
5992     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
5993                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
5994     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
5995                           MSIINSTALLCONTEXT_MACHINE, NULL);
5996     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
5997                           MSIINSTALLCONTEXT_MACHINE, NULL);
5998     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
5999                           MSIINSTALLCONTEXT_MACHINE, NULL);
6000     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
6001                           MSIINSTALLCONTEXT_MACHINE, NULL);
6002
6003     DeleteFileA("FileName1");
6004     DeleteFileA("FileName2");
6005     DeleteFileA("FileName3");
6006     DeleteFileA("FileName4");
6007     DeleteFileA("FileName5");
6008     DeleteFileA("FileName6");
6009     DeleteFileA("FileName7");
6010     MsiCloseHandle(hpkg);
6011     DeleteFileA(msifile);
6012 }
6013
6014 static void test_appsearch_reglocator(void)
6015 {
6016     MSIHANDLE hpkg, hdb;
6017     CHAR path[MAX_PATH];
6018     CHAR prop[MAX_PATH];
6019     DWORD binary[2];
6020     DWORD size, val;
6021     HKEY hklm, classes;
6022     HKEY hkcu, users;
6023     LPCSTR str;
6024     LONG res;
6025     UINT r;
6026
6027     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
6028     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6029
6030     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
6031                          (const BYTE *)"regszdata", 10);
6032     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6033
6034     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
6035     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6036
6037     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
6038                          (const BYTE *)"regszdata", 10);
6039     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6040
6041     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
6042     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6043
6044     res = RegSetValueExA(users, "Value1", 0, REG_SZ,
6045                          (const BYTE *)"regszdata", 10);
6046     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6047
6048     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
6049     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6050
6051     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
6052     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6053
6054     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
6055                          (const BYTE *)"regszdata", 10);
6056     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6057
6058     val = 42;
6059     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
6060                          (const BYTE *)&val, sizeof(DWORD));
6061     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6062
6063     val = -42;
6064     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
6065                          (const BYTE *)&val, sizeof(DWORD));
6066     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6067
6068     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
6069                          (const BYTE *)"%PATH%", 7);
6070     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6071
6072     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
6073                          (const BYTE *)"my%NOVAR%", 10);
6074     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6075
6076     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
6077                          (const BYTE *)"one\0two\0", 9);
6078     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6079
6080     binary[0] = 0x1234abcd;
6081     binary[1] = 0x567890ef;
6082     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
6083                          (const BYTE *)binary, sizeof(binary));
6084     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6085
6086     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
6087                          (const BYTE *)"#regszdata", 11);
6088     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6089
6090     create_test_file("FileName1");
6091     sprintf(path, "%s\\FileName1", CURR_DIR);
6092     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
6093                          (const BYTE *)path, lstrlenA(path) + 1);
6094     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6095
6096     sprintf(path, "%s\\FileName2", CURR_DIR);
6097     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
6098                          (const BYTE *)path, lstrlenA(path) + 1);
6099     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6100
6101     lstrcpyA(path, CURR_DIR);
6102     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
6103                          (const BYTE *)path, lstrlenA(path) + 1);
6104     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6105
6106     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
6107                          (const BYTE *)"", 1);
6108     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6109
6110     hdb = create_package_db();
6111     ok(hdb, "Expected a valid database handle\n");
6112
6113     r = create_appsearch_table(hdb);
6114     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6115
6116     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
6117     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6118
6119     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
6120     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6121
6122     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
6123     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6124
6125     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
6126     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6127
6128     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
6129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6130
6131     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
6132     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6133
6134     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
6135     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6136
6137     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
6138     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6139
6140     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
6141     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6142
6143     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
6144     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6145
6146     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
6147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6148
6149     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
6150     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6151
6152     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
6153     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6154
6155     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
6156     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6157
6158     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
6159     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6160
6161     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
6162     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6163
6164     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
6165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6166
6167     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
6168     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6169
6170     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
6171     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6172
6173     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignatur20'");
6174     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6175
6176     r = create_reglocator_table(hdb);
6177     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6178
6179     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
6180     str = "'NewSignature1', 2, 'Software\\Wine', 'Value1', 2";
6181     r = add_reglocator_entry(hdb, str);
6182     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6183
6184     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
6185     str = "'NewSignature2', 2, 'Software\\Wine', 'Value2', 2";
6186     r = add_reglocator_entry(hdb, str);
6187     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6188
6189     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
6190     str = "'NewSignature3', 2, 'Software\\Wine', 'Value3', 2";
6191     r = add_reglocator_entry(hdb, str);
6192     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6193
6194     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
6195     str = "'NewSignature4', 2, 'Software\\Wine', 'Value4', 2";
6196     r = add_reglocator_entry(hdb, str);
6197     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6198
6199     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
6200     str = "'NewSignature5', 2, 'Software\\Wine', 'Value5', 2";
6201     r = add_reglocator_entry(hdb, str);
6202     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6203
6204     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
6205     str = "'NewSignature6', 2, 'Software\\Wine', 'Value6', 2";
6206     r = add_reglocator_entry(hdb, str);
6207     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6208
6209     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
6210     str = "'NewSignature7', 2, 'Software\\Wine', 'Value7', 2";
6211     r = add_reglocator_entry(hdb, str);
6212     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6213
6214     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
6215     str = "'NewSignature8', 2, 'Software\\Wine', 'Value8', 2";
6216     r = add_reglocator_entry(hdb, str);
6217     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6218
6219     /* HKLM, msidbLocatorTypeFileName, file exists */
6220     str = "'NewSignature9', 2, 'Software\\Wine', 'Value9', 1";
6221     r = add_reglocator_entry(hdb, str);
6222     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6223
6224     /* HKLM, msidbLocatorTypeFileName, file does not exist */
6225     str = "'NewSignature10', 2, 'Software\\Wine', 'Value10', 1";
6226     r = add_reglocator_entry(hdb, str);
6227     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6228
6229     /* HKLM, msidbLocatorTypeFileName, no signature */
6230     str = "'NewSignature11', 2, 'Software\\Wine', 'Value9', 1";
6231     r = add_reglocator_entry(hdb, str);
6232     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6233
6234     /* HKLM, msidbLocatorTypeDirectory, file exists */
6235     str = "'NewSignature12', 2, 'Software\\Wine', 'Value9', 0";
6236     r = add_reglocator_entry(hdb, str);
6237     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6238
6239     /* HKLM, msidbLocatorTypeDirectory, directory */
6240     str = "'NewSignature13', 2, 'Software\\Wine', 'Value11', 0";
6241     r = add_reglocator_entry(hdb, str);
6242     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6243
6244     /* HKLM, msidbLocatorTypeDirectory, file exists, with signature */
6245     str = "'NewSignature14', 2, 'Software\\Wine', 'Value9', 0";
6246     r = add_reglocator_entry(hdb, str);
6247     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6248
6249     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
6250     str = "'NewSignature15', 0, 'Software\\Wine', 'Value1', 2";
6251     r = add_reglocator_entry(hdb, str);
6252     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6253
6254     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
6255     str = "'NewSignature16', 1, 'Software\\Wine', 'Value1', 2";
6256     r = add_reglocator_entry(hdb, str);
6257     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6258
6259     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
6260     str = "'NewSignature17', 3, 'S-1-5-18\\Software\\Wine', 'Value1', 2";
6261     r = add_reglocator_entry(hdb, str);
6262     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6263
6264     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
6265     str = "'NewSignature18', 2, 'Software\\Wine', '', 2";
6266     r = add_reglocator_entry(hdb, str);
6267     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6268
6269     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
6270     str = "'NewSignature19', 2, 'Software\\IDontExist', '', 2";
6271     r = add_reglocator_entry(hdb, str);
6272     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6273
6274     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
6275     str = "'NewSignature20', 2, 'Software\\Wine', 'Value12', 2";
6276     r = add_reglocator_entry(hdb, str);
6277     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6278
6279     r = create_signature_table(hdb);
6280     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6281
6282     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
6283     r = add_signature_entry(hdb, str);
6284     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6285
6286     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
6287     r = add_signature_entry(hdb, str);
6288     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6289
6290     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
6291     r = add_signature_entry(hdb, str);
6292     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6293
6294     hpkg = package_from_db(hdb);
6295     ok(hpkg, "Expected a valid package handle\n");
6296
6297     r = MsiDoAction(hpkg, "AppSearch");
6298     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6299
6300     size = MAX_PATH;
6301     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
6302     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6303     ok(!lstrcmpA(prop, "regszdata"),
6304        "Expected \"regszdata\", got \"%s\"\n", prop);
6305
6306     size = MAX_PATH;
6307     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
6308     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6309     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
6310
6311     size = MAX_PATH;
6312     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
6313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6314     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
6315
6316     ExpandEnvironmentStringsA("%PATH%", path, MAX_PATH);
6317
6318     size = MAX_PATH;
6319     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
6320     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6321     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6322
6323     size = MAX_PATH;
6324     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
6325     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6326     ok(!lstrcmpA(prop,
6327        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
6328
6329     size = MAX_PATH;
6330     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
6331     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6332     todo_wine
6333     {
6334         ok(!memcmp(prop, "\0one\0two\0\0", 10),
6335            "Expected \"\\0one\\0two\\0\\0\"\n");
6336     }
6337
6338     size = MAX_PATH;
6339     lstrcpyA(path, "#xCDAB3412EF907856");
6340     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
6341     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6342     todo_wine
6343     {
6344         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6345     }
6346
6347     size = MAX_PATH;
6348     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
6349     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6350     ok(!lstrcmpA(prop, "##regszdata"),
6351        "Expected \"##regszdata\", got \"%s\"\n", prop);
6352
6353     size = MAX_PATH;
6354     sprintf(path, "%s\\FileName1", CURR_DIR);
6355     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
6356     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6357     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6358
6359     size = MAX_PATH;
6360     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
6361     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6362     todo_wine
6363     {
6364         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6365     }
6366
6367     size = MAX_PATH;
6368     sprintf(path, "%s\\", CURR_DIR);
6369     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
6370     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6371     todo_wine
6372     {
6373         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6374     }
6375
6376     size = MAX_PATH;
6377     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
6378     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6379     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6380
6381     size = MAX_PATH;
6382     sprintf(path, "%s\\", CURR_DIR);
6383     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
6384     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6385     todo_wine
6386     {
6387         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6388     }
6389
6390     size = MAX_PATH;
6391     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
6392     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6393     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6394
6395     size = MAX_PATH;
6396     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
6397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6398     ok(!lstrcmpA(prop, "regszdata"),
6399        "Expected \"regszdata\", got \"%s\"\n", prop);
6400
6401     size = MAX_PATH;
6402     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
6403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6404     ok(!lstrcmpA(prop, "regszdata"),
6405        "Expected \"regszdata\", got \"%s\"\n", prop);
6406
6407     size = MAX_PATH;
6408     r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
6409     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6410     ok(!lstrcmpA(prop, "regszdata"),
6411        "Expected \"regszdata\", got \"%s\"\n", prop);
6412
6413     size = MAX_PATH;
6414     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
6415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6416     ok(!lstrcmpA(prop, "defvalue"),
6417        "Expected \"defvalue\", got \"%s\"\n", prop);
6418
6419     size = MAX_PATH;
6420     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
6421     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6422     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6423
6424     size = MAX_PATH;
6425     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
6426     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6427     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6428
6429     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
6430     RegDeleteValueA(hklm, "Value1");
6431     RegDeleteValueA(hklm, "Value2");
6432     RegDeleteValueA(hklm, "Value3");
6433     RegDeleteValueA(hklm, "Value4");
6434     RegDeleteValueA(hklm, "Value5");
6435     RegDeleteValueA(hklm, "Value6");
6436     RegDeleteValueA(hklm, "Value7");
6437     RegDeleteValueA(hklm, "Value8");
6438     RegDeleteValueA(hklm, "Value9");
6439     RegDeleteValueA(hklm, "Value10");
6440     RegDeleteValueA(hklm, "Value11");
6441     RegDeleteValueA(hklm, "Value12");
6442     RegDeleteKeyA(hklm, "");
6443     RegCloseKey(hklm);
6444
6445     RegDeleteValueA(classes, "Value1");
6446     RegDeleteKeyA(classes, "");
6447     RegCloseKey(classes);
6448
6449     RegDeleteValueA(hkcu, "Value1");
6450     RegDeleteKeyA(hkcu, "");
6451     RegCloseKey(hkcu);
6452
6453     RegDeleteValueA(users, "Value1");
6454     RegDeleteKeyA(users, "");
6455     RegCloseKey(users);
6456
6457     DeleteFileA("FileName1");
6458     MsiCloseHandle(hpkg);
6459     DeleteFileA(msifile);
6460 }
6461
6462 static void delete_win_ini(LPCSTR file)
6463 {
6464     CHAR path[MAX_PATH];
6465
6466     GetWindowsDirectoryA(path, MAX_PATH);
6467     lstrcatA(path, "\\");
6468     lstrcatA(path, file);
6469
6470     DeleteFileA(path);
6471 }
6472
6473 static void test_appsearch_inilocator(void)
6474 {
6475     MSIHANDLE hpkg, hdb;
6476     CHAR path[MAX_PATH];
6477     CHAR prop[MAX_PATH];
6478     LPCSTR str;
6479     LPSTR ptr;
6480     DWORD size;
6481     UINT r;
6482
6483     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
6484
6485     create_test_file("FileName1");
6486     sprintf(path, "%s\\FileName1", CURR_DIR);
6487     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
6488
6489     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
6490
6491     sprintf(path, "%s\\IDontExist", CURR_DIR);
6492     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
6493
6494     hdb = create_package_db();
6495     ok(hdb, "Expected a valid database handle\n");
6496
6497     r = create_appsearch_table(hdb);
6498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6499
6500     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
6501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6502
6503     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
6504     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6505
6506     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
6507     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6508
6509     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
6510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6511
6512     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
6513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6514
6515     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
6516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6517
6518     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
6519     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6520
6521     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
6522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6523
6524     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
6525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6526
6527     r = create_inilocator_table(hdb);
6528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6529
6530     /* msidbLocatorTypeRawValue, field 1 */
6531     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
6532     r = add_inilocator_entry(hdb, str);
6533     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6534
6535     /* msidbLocatorTypeRawValue, field 2 */
6536     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
6537     r = add_inilocator_entry(hdb, str);
6538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6539
6540     /* msidbLocatorTypeRawValue, entire field */
6541     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
6542     r = add_inilocator_entry(hdb, str);
6543     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6544
6545     /* msidbLocatorTypeFile */
6546     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
6547     r = add_inilocator_entry(hdb, str);
6548     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6549
6550     /* msidbLocatorTypeDirectory, file */
6551     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
6552     r = add_inilocator_entry(hdb, str);
6553     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6554
6555     /* msidbLocatorTypeDirectory, directory */
6556     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
6557     r = add_inilocator_entry(hdb, str);
6558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6559
6560     /* msidbLocatorTypeFile, file, no signature */
6561     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
6562     r = add_inilocator_entry(hdb, str);
6563     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6564
6565     /* msidbLocatorTypeFile, dir, no signature */
6566     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
6567     r = add_inilocator_entry(hdb, str);
6568     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6569
6570     /* msidbLocatorTypeFile, file does not exist */
6571     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
6572     r = add_inilocator_entry(hdb, str);
6573     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6574
6575     r = create_signature_table(hdb);
6576     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6577
6578     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
6579     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6580
6581     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
6582     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6583
6584     hpkg = package_from_db(hdb);
6585     ok(hpkg, "Expected a valid package handle\n");
6586
6587     r = MsiDoAction(hpkg, "AppSearch");
6588     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6589
6590     size = MAX_PATH;
6591     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
6592     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6593     todo_wine
6594     {
6595         ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
6596     }
6597
6598     size = MAX_PATH;
6599     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
6600     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6601     todo_wine
6602     {
6603         ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
6604     }
6605
6606     size = MAX_PATH;
6607     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
6608     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6609     ok(!lstrcmpA(prop, "keydata,field2"),
6610        "Expected \"keydata,field2\", got \"%s\"\n", prop);
6611
6612     size = MAX_PATH;
6613     sprintf(path, "%s\\FileName1", CURR_DIR);
6614     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
6615     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6616     todo_wine
6617     {
6618         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6619     }
6620
6621     size = MAX_PATH;
6622     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
6623     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6624     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6625
6626     size = MAX_PATH;
6627     sprintf(path, "%s\\", CURR_DIR);
6628     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
6629     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6630     todo_wine
6631     {
6632         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6633     }
6634
6635     size = MAX_PATH;
6636     sprintf(path, "%s\\", CURR_DIR);
6637     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
6638     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6639     todo_wine
6640     {
6641         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6642     }
6643
6644     size = MAX_PATH;
6645     lstrcpyA(path, CURR_DIR);
6646     ptr = strrchr(path, '\\');
6647     *(ptr + 1) = '\0';
6648     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
6649     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6650     todo_wine
6651     {
6652         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6653     }
6654
6655     size = MAX_PATH;
6656     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
6657     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6658     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6659
6660     delete_win_ini("IniFile.ini");
6661     DeleteFileA("FileName1");
6662     MsiCloseHandle(hpkg);
6663     DeleteFileA(msifile);
6664 }
6665
6666 static void test_appsearch_drlocator(void)
6667 {
6668     MSIHANDLE hpkg, hdb;
6669     CHAR path[MAX_PATH];
6670     CHAR prop[MAX_PATH];
6671     LPCSTR str;
6672     DWORD size;
6673     UINT r;
6674
6675     create_test_file("FileName1");
6676     CreateDirectoryA("one", NULL);
6677     CreateDirectoryA("one\\two", NULL);
6678     CreateDirectoryA("one\\two\\three", NULL);
6679     create_test_file("one\\two\\three\\FileName2");
6680     CreateDirectoryA("another", NULL);
6681
6682     hdb = create_package_db();
6683     ok(hdb, "Expected a valid database handle\n");
6684
6685     r = create_appsearch_table(hdb);
6686     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6687
6688     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
6689     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6690
6691     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
6692     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6693
6694     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
6695     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6696
6697     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
6698     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6699
6700     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
6701     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6702
6703     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
6704     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6705
6706     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
6707     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6708
6709     r = create_drlocator_table(hdb);
6710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6711
6712     /* no parent, full path, depth 0, signature */
6713     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
6714     r = add_drlocator_entry(hdb, path);
6715     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6716
6717     /* no parent, full path, depth 0, no signature */
6718     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
6719     r = add_drlocator_entry(hdb, path);
6720     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6721
6722     /* no parent, relative path, depth 0, no signature */
6723     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
6724     r = add_drlocator_entry(hdb, path);
6725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6726
6727     /* no parent, full path, depth 2, signature */
6728     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
6729     r = add_drlocator_entry(hdb, path);
6730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6731
6732     /* no parent, full path, depth 3, signature */
6733     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
6734     r = add_drlocator_entry(hdb, path);
6735     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6736
6737     /* no parent, full path, depth 1, signature is dir */
6738     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
6739     r = add_drlocator_entry(hdb, path);
6740     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6741
6742     /* parent is in DrLocator, relative path, depth 0, signature */
6743     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
6744     r = add_drlocator_entry(hdb, path);
6745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6746
6747     r = create_signature_table(hdb);
6748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6749
6750     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
6751     r = add_signature_entry(hdb, str);
6752     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6753
6754     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
6755     r = add_signature_entry(hdb, str);
6756     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6757
6758     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
6759     r = add_signature_entry(hdb, str);
6760     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6761
6762     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
6763     r = add_signature_entry(hdb, str);
6764     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6765
6766     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
6767     r = add_signature_entry(hdb, str);
6768     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6769
6770     hpkg = package_from_db(hdb);
6771     ok(hpkg, "Expected a valid package handle\n");
6772
6773     r = MsiDoAction(hpkg, "AppSearch");
6774     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6775
6776     size = MAX_PATH;
6777     sprintf(path, "%s\\FileName1", CURR_DIR);
6778     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
6779     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6780     todo_wine
6781     {
6782         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6783     }
6784
6785     size = MAX_PATH;
6786     sprintf(path, "%s\\", CURR_DIR);
6787     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
6788     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6789     todo_wine
6790     {
6791         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6792     }
6793
6794     size = MAX_PATH;
6795     sprintf(path, "%s\\", CURR_DIR);
6796     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
6797     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6798     todo_wine
6799     {
6800         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6801     }
6802
6803     size = MAX_PATH;
6804     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
6805     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6806     todo_wine
6807     {
6808         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6809     }
6810
6811     size = MAX_PATH;
6812     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
6813     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
6814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6815     todo_wine
6816     {
6817         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6818     }
6819
6820     size = MAX_PATH;
6821     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
6822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6823     todo_wine
6824     {
6825         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6826     }
6827
6828     size = MAX_PATH;
6829     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
6830     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
6831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6832     todo_wine
6833     {
6834         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6835     }
6836
6837     DeleteFileA("FileName1");
6838     DeleteFileA("one\\two\\three\\FileName2");
6839     RemoveDirectoryA("one\\two\\three");
6840     RemoveDirectoryA("one\\two");
6841     RemoveDirectoryA("one");
6842     RemoveDirectoryA("another");
6843     MsiCloseHandle(hpkg);
6844     DeleteFileA(msifile);
6845 }
6846
6847 static void test_featureparents(void)
6848 {
6849     MSIHANDLE hpkg;
6850     UINT r;
6851     MSIHANDLE hdb;
6852     INSTALLSTATE state, action;
6853
6854     hdb = create_package_db();
6855     ok ( hdb, "failed to create package database\n" );
6856
6857     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
6858     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
6859
6860     r = create_feature_table( hdb );
6861     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
6862
6863     r = create_component_table( hdb );
6864     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
6865
6866     r = create_feature_components_table( hdb );
6867     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
6868
6869     r = create_file_table( hdb );
6870     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
6871
6872     /* msidbFeatureAttributesFavorLocal */
6873     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
6874     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
6875
6876     /* msidbFeatureAttributesFavorSource */
6877     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
6878     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
6879
6880     /* msidbFeatureAttributesFavorLocal */
6881     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
6882     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
6883
6884     /* disabled because of install level */
6885     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
6886     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
6887
6888     /* child feature of disabled feature */
6889     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
6890     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
6891
6892     /* component of disabled feature (install level) */
6893     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
6894     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6895
6896     /* component of disabled child feature (install level) */
6897     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
6898     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6899
6900     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
6901     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
6902     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6903
6904     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
6905     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
6906     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6907
6908     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
6909     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
6910     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6911
6912     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
6913     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
6914     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6915
6916     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
6917     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
6918     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6919
6920     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
6921     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
6922     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6923
6924     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
6925     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
6926     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6927
6928     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
6929     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
6930     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
6931
6932     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
6933     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
6934
6935     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
6936     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6937
6938     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
6939     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6940
6941     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
6942     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6943
6944     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
6945     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6946
6947     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
6948     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6949
6950     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
6951     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6952
6953     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
6954     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6955
6956     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
6957     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6958
6959     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
6960     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6961
6962     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
6963     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6964
6965     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
6966     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6967
6968     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
6969     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6970
6971     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
6972     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6973
6974     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
6975     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6976
6977     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
6978     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6979
6980     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
6981     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6982
6983     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
6984     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
6985
6986     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
6987     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
6988
6989     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
6990     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
6991
6992     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
6993     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
6994
6995     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
6996     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
6997
6998     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
6999     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7000
7001     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
7002     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7003
7004     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
7005     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7006
7007     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
7008     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7009
7010     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
7011     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7012
7013     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
7014     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7015
7016     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
7017     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7018
7019     hpkg = package_from_db( hdb );
7020     ok( hpkg, "failed to create package\n");
7021
7022     MsiCloseHandle( hdb );
7023
7024     r = MsiDoAction( hpkg, "CostInitialize");
7025     ok( r == ERROR_SUCCESS, "cost init failed\n");
7026
7027     r = MsiDoAction( hpkg, "FileCost");
7028     ok( r == ERROR_SUCCESS, "file cost failed\n");
7029
7030     r = MsiDoAction( hpkg, "CostFinalize");
7031     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7032
7033     state = 0xdeadbee;
7034     action = 0xdeadbee;
7035     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
7036     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7037     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7038     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7039
7040     state = 0xdeadbee;
7041     action = 0xdeadbee;
7042     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
7043     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7044     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7045     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7046
7047     state = 0xdeadbee;
7048     action = 0xdeadbee;
7049     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
7050     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7051     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7052     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7053
7054     state = 0xdeadbee;
7055     action = 0xdeadbee;
7056     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
7057     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7058     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7059     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7060
7061     state = 0xdeadbee;
7062     action = 0xdeadbee;
7063     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
7064     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7065     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7066     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7067
7068     state = 0xdeadbee;
7069     action = 0xdeadbee;
7070     r = MsiGetComponentState(hpkg, "leo", &state, &action);
7071     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7072     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7073     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7074
7075     state = 0xdeadbee;
7076     action = 0xdeadbee;
7077     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
7078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7079     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
7080     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
7081
7082     state = 0xdeadbee;
7083     action = 0xdeadbee;
7084     r = MsiGetComponentState(hpkg, "libra", &state, &action);
7085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7086     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
7087     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
7088
7089     state = 0xdeadbee;
7090     action = 0xdeadbee;
7091     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
7092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7093     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
7094     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
7095
7096     state = 0xdeadbee;
7097     action = 0xdeadbee;
7098     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
7099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7100     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
7101     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
7102
7103     state = 0xdeadbee;
7104     action = 0xdeadbee;
7105     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
7106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7107     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
7108     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
7109
7110     state = 0xdeadbee;
7111     action = 0xdeadbee;
7112     r = MsiGetComponentState(hpkg, "canis", &state, &action);
7113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7114     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
7115     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
7116
7117     state = 0xdeadbee;
7118     action = 0xdeadbee;
7119     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
7120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7121     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
7122     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
7123
7124     state = 0xdeadbee;
7125     action = 0xdeadbee;
7126     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
7127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7128     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
7129     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
7130
7131     state = 0xdeadbee;
7132     action = 0xdeadbee;
7133     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
7134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7135     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
7136     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
7137
7138     state = 0xdeadbee;
7139     action = 0xdeadbee;
7140     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
7141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7142     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
7143     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
7144
7145     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
7146     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
7147
7148     state = 0xdeadbee;
7149     action = 0xdeadbee;
7150     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
7151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7152     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
7153     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
7154
7155     state = 0xdeadbee;
7156     action = 0xdeadbee;
7157     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
7158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7159     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
7160     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
7161
7162     state = 0xdeadbee;
7163     action = 0xdeadbee;
7164     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
7165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7166     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
7167     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
7168
7169     state = 0xdeadbee;
7170     action = 0xdeadbee;
7171     r = MsiGetComponentState(hpkg, "leo", &state, &action);
7172     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7173     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
7174     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
7175
7176     state = 0xdeadbee;
7177     action = 0xdeadbee;
7178     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
7179     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7180     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
7181     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
7182
7183     state = 0xdeadbee;
7184     action = 0xdeadbee;
7185     r = MsiGetComponentState(hpkg, "libra", &state, &action);
7186     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7187     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
7188     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
7189
7190     state = 0xdeadbee;
7191     action = 0xdeadbee;
7192     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
7193     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7194     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
7195     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
7196
7197     state = 0xdeadbee;
7198     action = 0xdeadbee;
7199     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
7200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7201     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
7202     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
7203
7204     state = 0xdeadbee;
7205     action = 0xdeadbee;
7206     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
7207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7208     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
7209     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
7210
7211     state = 0xdeadbee;
7212     action = 0xdeadbee;
7213     r = MsiGetComponentState(hpkg, "canis", &state, &action);
7214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7215     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
7216     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
7217
7218     state = 0xdeadbee;
7219     action = 0xdeadbee;
7220     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
7221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7222     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
7223     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
7224
7225     state = 0xdeadbee;
7226     action = 0xdeadbee;
7227     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
7228     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7229     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
7230     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
7231
7232     state = 0xdeadbee;
7233     action = 0xdeadbee;
7234     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
7235     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7236     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
7237     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
7238
7239     state = 0xdeadbee;
7240     action = 0xdeadbee;
7241     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
7242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7243     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
7244     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
7245     
7246     MsiCloseHandle(hpkg);
7247     DeleteFileA(msifile);
7248 }
7249
7250 static void test_installprops(void)
7251 {
7252     MSIHANDLE hpkg, hdb;
7253     CHAR path[MAX_PATH];
7254     CHAR buf[MAX_PATH];
7255     DWORD size, type;
7256     LANGID langid;
7257     HKEY hkey1, hkey2;
7258     int res;
7259     UINT r;
7260
7261     GetCurrentDirectory(MAX_PATH, path);
7262     lstrcat(path, "\\");
7263     lstrcat(path, msifile);
7264
7265     hdb = create_package_db();
7266     ok( hdb, "failed to create database\n");
7267
7268     hpkg = package_from_db(hdb);
7269     ok( hpkg, "failed to create package\n");
7270
7271     MsiCloseHandle(hdb);
7272
7273     size = MAX_PATH;
7274     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
7275     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7276     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
7277
7278     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
7279
7280     RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
7281
7282     size = MAX_PATH;
7283     type = REG_SZ;
7284     *path = '\0';
7285     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
7286     {
7287         size = MAX_PATH;
7288         type = REG_SZ;
7289         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
7290     }
7291
7292     /* win9x doesn't set this */
7293     if (*path)
7294     {
7295         size = MAX_PATH;
7296         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
7297         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7298         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
7299     }
7300
7301     size = MAX_PATH;
7302     type = REG_SZ;
7303     *path = '\0';
7304     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
7305     {
7306         size = MAX_PATH;
7307         type = REG_SZ;
7308         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
7309     }
7310
7311     if (*path)
7312     {
7313         size = MAX_PATH;
7314         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
7315         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7316         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
7317     }
7318
7319     size = MAX_PATH;
7320     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
7321     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7322     trace("VersionDatabase = %s\n", buf);
7323
7324     size = MAX_PATH;
7325     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
7326     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7327     trace("VersionMsi = %s\n", buf);
7328
7329     size = MAX_PATH;
7330     r = MsiGetProperty(hpkg, "Date", buf, &size);
7331     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7332     trace("Date = %s\n", buf);
7333
7334     size = MAX_PATH;
7335     r = MsiGetProperty(hpkg, "Time", buf, &size);
7336     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7337     trace("Time = %s\n", buf);
7338
7339     size = MAX_PATH;
7340     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
7341     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7342     trace("PackageCode = %s\n", buf);
7343
7344     langid = GetUserDefaultLangID();
7345     sprintf(path, "%d", langid);
7346
7347     size = MAX_PATH;
7348     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
7349     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
7350     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
7351
7352     res = GetSystemMetrics(SM_CXSCREEN);
7353     size = MAX_PATH;
7354     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
7355     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
7356
7357     res = GetSystemMetrics(SM_CYSCREEN);
7358     size = MAX_PATH;
7359     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
7360     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
7361
7362     CloseHandle(hkey1);
7363     CloseHandle(hkey2);
7364     MsiCloseHandle(hpkg);
7365     DeleteFile(msifile);
7366 }
7367
7368 static void test_launchconditions(void)
7369 {
7370     MSIHANDLE hpkg;
7371     MSIHANDLE hdb;
7372     UINT r;
7373
7374     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7375
7376     hdb = create_package_db();
7377     ok( hdb, "failed to create package database\n" );
7378
7379     r = create_launchcondition_table( hdb );
7380     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
7381
7382     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
7383     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
7384
7385     /* invalid condition */
7386     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
7387     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
7388
7389     hpkg = package_from_db( hdb );
7390     ok( hpkg, "failed to create package\n");
7391
7392     MsiCloseHandle( hdb );
7393
7394     r = MsiSetProperty( hpkg, "X", "1" );
7395     ok( r == ERROR_SUCCESS, "failed to set property\n" );
7396
7397     /* invalid conditions are ignored */
7398     r = MsiDoAction( hpkg, "LaunchConditions" );
7399     ok( r == ERROR_SUCCESS, "cost init failed\n" );
7400
7401     /* verify LaunchConditions still does some verification */
7402     r = MsiSetProperty( hpkg, "X", "2" );
7403     ok( r == ERROR_SUCCESS, "failed to set property\n" );
7404
7405     r = MsiDoAction( hpkg, "LaunchConditions" );
7406     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
7407
7408     MsiCloseHandle( hpkg );
7409     DeleteFile( msifile );
7410 }
7411
7412 static void test_ccpsearch(void)
7413 {
7414     MSIHANDLE hdb, hpkg;
7415     CHAR prop[MAX_PATH];
7416     DWORD size = MAX_PATH;
7417     UINT r;
7418
7419     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7420
7421     hdb = create_package_db();
7422     ok(hdb, "failed to create package database\n");
7423
7424     r = create_ccpsearch_table(hdb);
7425     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7426
7427     r = add_ccpsearch_entry(hdb, "'CCP_random'");
7428     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7429
7430     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
7431     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7432
7433     r = create_reglocator_table(hdb);
7434     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7435
7436     r = add_reglocator_entry(hdb, "'CCP_random', 0, 'htmlfile\\shell\\open\\nonexistent', '', 1");
7437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7438
7439     r = create_drlocator_table(hdb);
7440     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7441
7442     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
7443     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7444
7445     r = create_signature_table(hdb);
7446     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7447
7448     hpkg = package_from_db(hdb);
7449     ok(hpkg, "failed to create package\n");
7450
7451     MsiCloseHandle(hdb);
7452
7453     r = MsiDoAction(hpkg, "CCPSearch");
7454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7455
7456     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
7457     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7458     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
7459
7460     MsiCloseHandle(hpkg);
7461     DeleteFileA(msifile);
7462 }
7463
7464 static void test_complocator(void)
7465 {
7466     MSIHANDLE hdb, hpkg;
7467     UINT r;
7468     CHAR prop[MAX_PATH];
7469     CHAR expected[MAX_PATH];
7470     DWORD size = MAX_PATH;
7471
7472     hdb = create_package_db();
7473     ok(hdb, "failed to create package database\n");
7474
7475     r = create_appsearch_table(hdb);
7476     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7477
7478     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
7479     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7480
7481     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
7482     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7483
7484     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
7485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7486
7487     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
7488     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7489
7490     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
7491     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7492
7493     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
7494     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7495
7496     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
7497     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7498
7499     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
7500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7501
7502     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
7503     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7504
7505     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
7506     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7507
7508     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
7509     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7510
7511     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
7512     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7513
7514     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
7515     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7516
7517     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
7518     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7519
7520     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
7521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7522
7523     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
7524     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7525
7526     r = create_complocator_table(hdb);
7527     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7528
7529     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
7530     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7531
7532     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
7533     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7534
7535     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
7536     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7537
7538     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
7539     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7540
7541     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
7542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7543
7544     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
7545     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7546
7547     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
7548     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7549
7550     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
7551     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7552
7553     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
7554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7555
7556     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
7557     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7558
7559     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
7560     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7561
7562     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
7563     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7564
7565     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
7566     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7567
7568     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
7569     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7570
7571     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
7572     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7573
7574     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
7575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7576
7577     r = create_signature_table(hdb);
7578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7579
7580     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
7581     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7582
7583     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
7584     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7585
7586     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
7587     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7588
7589     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
7590     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7591
7592     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
7593     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7594
7595     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
7596     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7597
7598     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
7599     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7600
7601     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
7602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7603
7604     hpkg = package_from_db(hdb);
7605     ok(hpkg, "failed to create package\n");
7606
7607     MsiCloseHandle(hdb);
7608
7609     create_test_file("abelisaurus");
7610     create_test_file("bactrosaurus");
7611     create_test_file("camelotia");
7612     create_test_file("diclonius");
7613     create_test_file("echinodon");
7614     create_test_file("falcarius");
7615     create_test_file("gallimimus");
7616     create_test_file("hagryphus");
7617     CreateDirectoryA("iguanodon", NULL);
7618     CreateDirectoryA("jobaria", NULL);
7619     CreateDirectoryA("kakuru", NULL);
7620     CreateDirectoryA("labocania", NULL);
7621     CreateDirectoryA("megaraptor", NULL);
7622     CreateDirectoryA("neosodon", NULL);
7623     CreateDirectoryA("olorotitan", NULL);
7624     CreateDirectoryA("pantydraco", NULL);
7625
7626     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
7627                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
7628     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
7629                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
7630     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
7631                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
7632     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
7633                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
7634     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
7635                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
7636     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
7637                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
7638     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
7639                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
7640     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
7641                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
7642
7643     r = MsiDoAction(hpkg, "AppSearch");
7644     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7645
7646     size = MAX_PATH;
7647     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
7648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7649
7650     lstrcpyA(expected, CURR_DIR);
7651     lstrcatA(expected, "\\abelisaurus");
7652     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
7653        "Expected %s or empty string, got %s\n", expected, prop);
7654
7655     size = MAX_PATH;
7656     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
7657     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7658     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7659
7660     size = MAX_PATH;
7661     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
7662     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7663     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7664
7665     size = MAX_PATH;
7666     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
7667     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7668     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7669
7670     size = MAX_PATH;
7671     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
7672     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7673
7674     lstrcpyA(expected, CURR_DIR);
7675     lstrcatA(expected, "\\");
7676     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
7677        "Expected %s or empty string, got %s\n", expected, prop);
7678
7679     size = MAX_PATH;
7680     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
7681     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7682     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7683
7684     size = MAX_PATH;
7685     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
7686     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7687     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7688
7689     size = MAX_PATH;
7690     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
7691     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7692     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7693
7694     size = MAX_PATH;
7695     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
7696     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7697     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7698
7699     size = MAX_PATH;
7700     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
7701     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7702     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7703
7704     size = MAX_PATH;
7705     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
7706     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7707     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7708
7709     size = MAX_PATH;
7710     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
7711     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7712     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7713
7714     size = MAX_PATH;
7715     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
7716     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7717
7718     lstrcpyA(expected, CURR_DIR);
7719     lstrcatA(expected, "\\");
7720     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
7721        "Expected %s or empty string, got %s\n", expected, prop);
7722
7723     size = MAX_PATH;
7724     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
7725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7726
7727     lstrcpyA(expected, CURR_DIR);
7728     lstrcatA(expected, "\\neosodon\\");
7729     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
7730        "Expected %s or empty string, got %s\n", expected, prop);
7731
7732     size = MAX_PATH;
7733     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
7734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7735     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7736
7737     size = MAX_PATH;
7738     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
7739     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7740     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7741
7742     MsiCloseHandle(hpkg);
7743     DeleteFileA("abelisaurus");
7744     DeleteFileA("bactrosaurus");
7745     DeleteFileA("camelotia");
7746     DeleteFileA("diclonius");
7747     DeleteFileA("echinodon");
7748     DeleteFileA("falcarius");
7749     DeleteFileA("gallimimus");
7750     DeleteFileA("hagryphus");
7751     RemoveDirectoryA("iguanodon");
7752     RemoveDirectoryA("jobaria");
7753     RemoveDirectoryA("kakuru");
7754     RemoveDirectoryA("labocania");
7755     RemoveDirectoryA("megaraptor");
7756     RemoveDirectoryA("neosodon");
7757     RemoveDirectoryA("olorotitan");
7758     RemoveDirectoryA("pantydraco");
7759     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
7760                           MSIINSTALLCONTEXT_MACHINE, NULL);
7761     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
7762                           MSIINSTALLCONTEXT_MACHINE, NULL);
7763     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
7764                           MSIINSTALLCONTEXT_MACHINE, NULL);
7765     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
7766                           MSIINSTALLCONTEXT_MACHINE, NULL);
7767     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
7768                           MSIINSTALLCONTEXT_MACHINE, NULL);
7769     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
7770                           MSIINSTALLCONTEXT_MACHINE, NULL);
7771     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
7772                           MSIINSTALLCONTEXT_MACHINE, NULL);
7773     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
7774                           MSIINSTALLCONTEXT_MACHINE, NULL);
7775     DeleteFileA(msifile);
7776 }
7777
7778 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
7779 {
7780     MSIHANDLE summary;
7781     UINT r;
7782
7783     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
7784     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7785
7786     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
7787     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7788
7789     r = MsiSummaryInfoPersist(summary);
7790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7791
7792     MsiCloseHandle(summary);
7793 }
7794
7795 static void test_MsiGetSourcePath(void)
7796 {
7797     MSIHANDLE hdb, hpkg;
7798     CHAR path[MAX_PATH];
7799     CHAR cwd[MAX_PATH];
7800     CHAR subsrc[MAX_PATH];
7801     CHAR sub2[MAX_PATH];
7802     DWORD size;
7803     UINT r;
7804
7805     lstrcpyA(cwd, CURR_DIR);
7806     lstrcatA(cwd, "\\");
7807
7808     lstrcpyA(subsrc, cwd);
7809     lstrcatA(subsrc, "subsource");
7810     lstrcatA(subsrc, "\\");
7811
7812     lstrcpyA(sub2, subsrc);
7813     lstrcatA(sub2, "sub2");
7814     lstrcatA(sub2, "\\");
7815
7816     /* uncompressed source */
7817
7818     hdb = create_package_db();
7819     ok( hdb, "failed to create database\n");
7820
7821     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7822
7823     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7824     ok(r == S_OK, "failed\n");
7825
7826     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
7827     ok(r == S_OK, "failed\n");
7828
7829     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
7830     ok(r == S_OK, "failed\n");
7831
7832     r = MsiDatabaseCommit(hdb);
7833     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
7834
7835     hpkg = package_from_db(hdb);
7836     ok(hpkg, "failed to create package\n");
7837
7838     MsiCloseHandle(hdb);
7839
7840     /* invalid database handle */
7841     size = MAX_PATH;
7842     lstrcpyA(path, "kiwi");
7843     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
7844     ok(r == ERROR_INVALID_HANDLE,
7845        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
7846     ok(!lstrcmpA(path, "kiwi"),
7847        "Expected path to be unchanged, got \"%s\"\n", path);
7848     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7849
7850     /* NULL szFolder */
7851     size = MAX_PATH;
7852     lstrcpyA(path, "kiwi");
7853     r = MsiGetSourcePath(hpkg, NULL, path, &size);
7854     ok(r == ERROR_INVALID_PARAMETER,
7855        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7856     ok(!lstrcmpA(path, "kiwi"),
7857        "Expected path to be unchanged, got \"%s\"\n", path);
7858     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7859
7860     /* empty szFolder */
7861     size = MAX_PATH;
7862     lstrcpyA(path, "kiwi");
7863     r = MsiGetSourcePath(hpkg, "", path, &size);
7864     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7865     ok(!lstrcmpA(path, "kiwi"),
7866        "Expected path to be unchanged, got \"%s\"\n", path);
7867     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7868
7869     /* try TARGETDIR */
7870     size = MAX_PATH;
7871     lstrcpyA(path, "kiwi");
7872     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7873     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7874     ok(!lstrcmpA(path, "kiwi"),
7875        "Expected path to be unchanged, got \"%s\"\n", path);
7876     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7877
7878     /* try SourceDir */
7879     size = MAX_PATH;
7880     lstrcpyA(path, "kiwi");
7881     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7882     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7883     ok(!lstrcmpA(path, "kiwi"),
7884        "Expected path to be unchanged, got \"%s\"\n", path);
7885     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7886
7887     /* try SOURCEDIR */
7888     size = MAX_PATH;
7889     lstrcpyA(path, "kiwi");
7890     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7891     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7892     ok(!lstrcmpA(path, "kiwi"),
7893        "Expected path to be unchanged, got \"%s\"\n", path);
7894     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7895
7896     /* source path does not exist, but the property exists */
7897     size = MAX_PATH;
7898     lstrcpyA(path, "kiwi");
7899     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7901     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7902     ok(size == 0, "Expected 0, got %d\n", size);
7903
7904     /* try SubDir */
7905     size = MAX_PATH;
7906     lstrcpyA(path, "kiwi");
7907     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7908     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7909     ok(!lstrcmpA(path, "kiwi"),
7910        "Expected path to be unchanged, got \"%s\"\n", path);
7911     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7912
7913     /* try SubDir2 */
7914     size = MAX_PATH;
7915     lstrcpyA(path, "kiwi");
7916     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7917     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7918     ok(!lstrcmpA(path, "kiwi"),
7919        "Expected path to be unchanged, got \"%s\"\n", path);
7920     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7921
7922     r = MsiDoAction(hpkg, "CostInitialize");
7923     ok(r == ERROR_SUCCESS, "cost init failed\n");
7924
7925     /* try TARGETDIR after CostInitialize */
7926     size = MAX_PATH;
7927     lstrcpyA(path, "kiwi");
7928     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7930     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7931     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7932
7933     /* try SourceDir after CostInitialize */
7934     size = MAX_PATH;
7935     lstrcpyA(path, "kiwi");
7936     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7937     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7938     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7939     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7940
7941     /* try SOURCEDIR after CostInitialize */
7942     size = MAX_PATH;
7943     lstrcpyA(path, "kiwi");
7944     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7945     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7946     ok(!lstrcmpA(path, "kiwi"),
7947        "Expected path to be unchanged, got \"%s\"\n", path);
7948     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7949
7950     /* source path does not exist, but the property exists */
7951     size = MAX_PATH;
7952     lstrcpyA(path, "kiwi");
7953     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7954     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7955     todo_wine
7956     {
7957         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7958         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7959     }
7960
7961     /* try SubDir after CostInitialize */
7962     size = MAX_PATH;
7963     lstrcpyA(path, "kiwi");
7964     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7965     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7966     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7967     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7968
7969     /* try SubDir2 after CostInitialize */
7970     size = MAX_PATH;
7971     lstrcpyA(path, "kiwi");
7972     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7974     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
7975     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
7976
7977     r = MsiDoAction(hpkg, "ResolveSource");
7978     ok(r == ERROR_SUCCESS, "file cost failed\n");
7979
7980     /* try TARGETDIR after ResolveSource */
7981     size = MAX_PATH;
7982     lstrcpyA(path, "kiwi");
7983     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7984     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7985     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7986     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7987
7988     /* try SourceDir after ResolveSource */
7989     size = MAX_PATH;
7990     lstrcpyA(path, "kiwi");
7991     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7992     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7993     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7994     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7995
7996     /* try SOURCEDIR after ResolveSource */
7997     size = MAX_PATH;
7998     lstrcpyA(path, "kiwi");
7999     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8000     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8001     ok(!lstrcmpA(path, "kiwi"),
8002        "Expected path to be unchanged, got \"%s\"\n", path);
8003     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8004
8005     /* source path does not exist, but the property exists */
8006     size = MAX_PATH;
8007     lstrcpyA(path, "kiwi");
8008     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8010     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8011     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8012
8013     /* try SubDir after ResolveSource */
8014     size = MAX_PATH;
8015     lstrcpyA(path, "kiwi");
8016     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8017     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8018     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8019     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8020
8021     /* try SubDir2 after ResolveSource */
8022     size = MAX_PATH;
8023     lstrcpyA(path, "kiwi");
8024     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8025     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8026     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8027     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8028
8029     r = MsiDoAction(hpkg, "FileCost");
8030     ok(r == ERROR_SUCCESS, "file cost failed\n");
8031
8032     /* try TARGETDIR after FileCost */
8033     size = MAX_PATH;
8034     lstrcpyA(path, "kiwi");
8035     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8036     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8037     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8038     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8039
8040     /* try SourceDir after FileCost */
8041     size = MAX_PATH;
8042     lstrcpyA(path, "kiwi");
8043     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8045     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8046     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8047
8048     /* try SOURCEDIR after FileCost */
8049     size = MAX_PATH;
8050     lstrcpyA(path, "kiwi");
8051     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8052     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8053     ok(!lstrcmpA(path, "kiwi"),
8054        "Expected path to be unchanged, got \"%s\"\n", path);
8055     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8056
8057     /* try SubDir after FileCost */
8058     size = MAX_PATH;
8059     lstrcpyA(path, "kiwi");
8060     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8061     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8062     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8063     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8064
8065     /* try SubDir2 after FileCost */
8066     size = MAX_PATH;
8067     lstrcpyA(path, "kiwi");
8068     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8070     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8071     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8072
8073     r = MsiDoAction(hpkg, "CostFinalize");
8074     ok(r == ERROR_SUCCESS, "file cost failed\n");
8075
8076     /* try TARGETDIR after CostFinalize */
8077     size = MAX_PATH;
8078     lstrcpyA(path, "kiwi");
8079     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8080     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8081     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8082     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8083
8084     /* try SourceDir after CostFinalize */
8085     size = MAX_PATH;
8086     lstrcpyA(path, "kiwi");
8087     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8088     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8089     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8090     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8091
8092     /* try SOURCEDIR after CostFinalize */
8093     size = MAX_PATH;
8094     lstrcpyA(path, "kiwi");
8095     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8096     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8097     ok(!lstrcmpA(path, "kiwi"),
8098        "Expected path to be unchanged, got \"%s\"\n", path);
8099     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8100
8101     /* try SubDir after CostFinalize */
8102     size = MAX_PATH;
8103     lstrcpyA(path, "kiwi");
8104     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8106     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8107     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8108
8109     /* try SubDir2 after CostFinalize */
8110     size = MAX_PATH;
8111     lstrcpyA(path, "kiwi");
8112     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8113     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8114     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8115     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8116
8117     /* nonexistent directory */
8118     size = MAX_PATH;
8119     lstrcpyA(path, "kiwi");
8120     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
8121     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8122     ok(!lstrcmpA(path, "kiwi"),
8123        "Expected path to be unchanged, got \"%s\"\n", path);
8124     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8125
8126     /* NULL szPathBuf */
8127     size = MAX_PATH;
8128     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
8129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8130     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8131
8132     /* NULL pcchPathBuf */
8133     lstrcpyA(path, "kiwi");
8134     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
8135     ok(r == ERROR_INVALID_PARAMETER,
8136        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8137     ok(!lstrcmpA(path, "kiwi"),
8138        "Expected path to be unchanged, got \"%s\"\n", path);
8139
8140     /* pcchPathBuf is 0 */
8141     size = 0;
8142     lstrcpyA(path, "kiwi");
8143     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8144     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8145     ok(!lstrcmpA(path, "kiwi"),
8146        "Expected path to be unchanged, got \"%s\"\n", path);
8147     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8148
8149     /* pcchPathBuf does not have room for NULL terminator */
8150     size = lstrlenA(cwd);
8151     lstrcpyA(path, "kiwi");
8152     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8153     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8154     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
8155        "Expected path with no backslash, got \"%s\"\n", path);
8156     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8157
8158     /* pcchPathBuf has room for NULL terminator */
8159     size = lstrlenA(cwd) + 1;
8160     lstrcpyA(path, "kiwi");
8161     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8162     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8163     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8164     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8165
8166     MsiCloseHandle(hpkg);
8167
8168     /* compressed source */
8169
8170     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
8171     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172
8173     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
8174
8175     hpkg = package_from_db(hdb);
8176     ok(hpkg, "failed to create package\n");
8177
8178     r = MsiDoAction(hpkg, "CostInitialize");
8179     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8180     r = MsiDoAction(hpkg, "FileCost");
8181     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8182     r = MsiDoAction(hpkg, "CostFinalize");
8183     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8184
8185     /* try TARGETDIR after CostFinalize */
8186     size = MAX_PATH;
8187     lstrcpyA(path, "kiwi");
8188     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8189     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8190     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8191     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8192
8193     /* try SourceDir after CostFinalize */
8194     size = MAX_PATH;
8195     lstrcpyA(path, "kiwi");
8196     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8197     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8198     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8199     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8200
8201     /* try SOURCEDIR after CostFinalize */
8202     size = MAX_PATH;
8203     lstrcpyA(path, "kiwi");
8204     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8205     todo_wine
8206     {
8207         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8208         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8209         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8210     }
8211
8212     /* try SubDir after CostFinalize */
8213     size = MAX_PATH;
8214     lstrcpyA(path, "kiwi");
8215     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8216     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8217     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8218     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8219
8220     /* try SubDir2 after CostFinalize */
8221     size = MAX_PATH;
8222     lstrcpyA(path, "kiwi");
8223     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8224     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8225     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8226     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8227
8228     MsiCloseHandle(hpkg);
8229     DeleteFile(msifile);
8230 }
8231
8232 static void test_shortlongsource(void)
8233 {
8234     MSIHANDLE hdb, hpkg;
8235     CHAR path[MAX_PATH];
8236     CHAR cwd[MAX_PATH];
8237     CHAR subsrc[MAX_PATH];
8238     DWORD size;
8239     UINT r;
8240
8241     lstrcpyA(cwd, CURR_DIR);
8242     lstrcatA(cwd, "\\");
8243
8244     lstrcpyA(subsrc, cwd);
8245     lstrcatA(subsrc, "long");
8246     lstrcatA(subsrc, "\\");
8247
8248     /* long file names */
8249
8250     hdb = create_package_db();
8251     ok( hdb, "failed to create database\n");
8252
8253     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
8254
8255     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
8256     ok(r == S_OK, "failed\n");
8257
8258     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
8259     ok(r == S_OK, "failed\n");
8260
8261     /* CostInitialize:short */
8262     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
8263     ok(r == S_OK, "failed\n");
8264
8265     /* CostInitialize:long */
8266     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
8267     ok(r == S_OK, "failed\n");
8268
8269     /* FileCost:short */
8270     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
8271     ok(r == S_OK, "failed\n");
8272
8273     /* FileCost:long */
8274     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
8275     ok(r == S_OK, "failed\n");
8276
8277     /* CostFinalize:short */
8278     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
8279     ok(r == S_OK, "failed\n");
8280
8281     /* CostFinalize:long */
8282     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
8283     ok(r == S_OK, "failed\n");
8284
8285     MsiDatabaseCommit(hdb);
8286
8287     hpkg = package_from_db(hdb);
8288     ok(hpkg, "failed to create package\n");
8289
8290     MsiCloseHandle(hdb);
8291
8292     CreateDirectoryA("one", NULL);
8293     CreateDirectoryA("four", NULL);
8294
8295     r = MsiDoAction(hpkg, "CostInitialize");
8296     ok(r == ERROR_SUCCESS, "file cost failed\n");
8297
8298     CreateDirectory("five", NULL);
8299     CreateDirectory("eight", NULL);
8300
8301     r = MsiDoAction(hpkg, "FileCost");
8302     ok(r == ERROR_SUCCESS, "file cost failed\n");
8303
8304     CreateDirectory("nine", NULL);
8305     CreateDirectory("twelve", NULL);
8306
8307     r = MsiDoAction(hpkg, "CostFinalize");
8308     ok(r == ERROR_SUCCESS, "file cost failed\n");
8309
8310     /* neither short nor long source directories exist */
8311     size = MAX_PATH;
8312     lstrcpyA(path, "kiwi");
8313     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8314     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8315     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8316     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8317
8318     CreateDirectoryA("short", NULL);
8319
8320     /* short source directory exists */
8321     size = MAX_PATH;
8322     lstrcpyA(path, "kiwi");
8323     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8324     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8325     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8326     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8327
8328     CreateDirectoryA("long", NULL);
8329
8330     /* both short and long source directories exist */
8331     size = MAX_PATH;
8332     lstrcpyA(path, "kiwi");
8333     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8334     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8335     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8336     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8337
8338     lstrcpyA(subsrc, cwd);
8339     lstrcatA(subsrc, "two");
8340     lstrcatA(subsrc, "\\");
8341
8342     /* short dir exists before CostInitialize */
8343     size = MAX_PATH;
8344     lstrcpyA(path, "kiwi");
8345     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8346     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8347     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8348     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8349
8350     lstrcpyA(subsrc, cwd);
8351     lstrcatA(subsrc, "four");
8352     lstrcatA(subsrc, "\\");
8353
8354     /* long dir exists before CostInitialize */
8355     size = MAX_PATH;
8356     lstrcpyA(path, "kiwi");
8357     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
8358     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8359     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8360     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8361
8362     lstrcpyA(subsrc, cwd);
8363     lstrcatA(subsrc, "six");
8364     lstrcatA(subsrc, "\\");
8365
8366     /* short dir exists before FileCost */
8367     size = MAX_PATH;
8368     lstrcpyA(path, "kiwi");
8369     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
8370     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8371     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8372     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8373
8374     lstrcpyA(subsrc, cwd);
8375     lstrcatA(subsrc, "eight");
8376     lstrcatA(subsrc, "\\");
8377
8378     /* long dir exists before FileCost */
8379     size = MAX_PATH;
8380     lstrcpyA(path, "kiwi");
8381     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
8382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8383     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8384     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8385
8386     lstrcpyA(subsrc, cwd);
8387     lstrcatA(subsrc, "ten");
8388     lstrcatA(subsrc, "\\");
8389
8390     /* short dir exists before CostFinalize */
8391     size = MAX_PATH;
8392     lstrcpyA(path, "kiwi");
8393     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
8394     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8395     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8396     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8397
8398     lstrcpyA(subsrc, cwd);
8399     lstrcatA(subsrc, "twelve");
8400     lstrcatA(subsrc, "\\");
8401
8402     /* long dir exists before CostFinalize */
8403     size = MAX_PATH;
8404     lstrcpyA(path, "kiwi");
8405     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
8406     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8407     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8408     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8409
8410     MsiCloseHandle(hpkg);
8411     RemoveDirectoryA("short");
8412     RemoveDirectoryA("long");
8413     RemoveDirectoryA("one");
8414     RemoveDirectoryA("four");
8415     RemoveDirectoryA("five");
8416     RemoveDirectoryA("eight");
8417     RemoveDirectoryA("nine");
8418     RemoveDirectoryA("twelve");
8419
8420     /* short file names */
8421
8422     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
8423     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8424
8425     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
8426
8427     hpkg = package_from_db(hdb);
8428     ok(hpkg, "failed to create package\n");
8429
8430     MsiCloseHandle(hdb);
8431
8432     CreateDirectoryA("one", NULL);
8433     CreateDirectoryA("four", NULL);
8434
8435     r = MsiDoAction(hpkg, "CostInitialize");
8436     ok(r == ERROR_SUCCESS, "file cost failed\n");
8437
8438     CreateDirectory("five", NULL);
8439     CreateDirectory("eight", NULL);
8440
8441     r = MsiDoAction(hpkg, "FileCost");
8442     ok(r == ERROR_SUCCESS, "file cost failed\n");
8443
8444     CreateDirectory("nine", NULL);
8445     CreateDirectory("twelve", NULL);
8446
8447     r = MsiDoAction(hpkg, "CostFinalize");
8448     ok(r == ERROR_SUCCESS, "file cost failed\n");
8449
8450     lstrcpyA(subsrc, cwd);
8451     lstrcatA(subsrc, "short");
8452     lstrcatA(subsrc, "\\");
8453
8454     /* neither short nor long source directories exist */
8455     size = MAX_PATH;
8456     lstrcpyA(path, "kiwi");
8457     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8458     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8459     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8460     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8461
8462     CreateDirectoryA("short", NULL);
8463
8464     /* short source directory exists */
8465     size = MAX_PATH;
8466     lstrcpyA(path, "kiwi");
8467     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8468     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8469     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8470     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8471
8472     CreateDirectoryA("long", NULL);
8473
8474     /* both short and long source directories exist */
8475     size = MAX_PATH;
8476     lstrcpyA(path, "kiwi");
8477     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8478     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8479     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8480     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8481
8482     lstrcpyA(subsrc, cwd);
8483     lstrcatA(subsrc, "one");
8484     lstrcatA(subsrc, "\\");
8485
8486     /* short dir exists before CostInitialize */
8487     size = MAX_PATH;
8488     lstrcpyA(path, "kiwi");
8489     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8490     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8491     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8492     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8493
8494     lstrcpyA(subsrc, cwd);
8495     lstrcatA(subsrc, "three");
8496     lstrcatA(subsrc, "\\");
8497
8498     /* long dir exists before CostInitialize */
8499     size = MAX_PATH;
8500     lstrcpyA(path, "kiwi");
8501     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
8502     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8503     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8504     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8505
8506     lstrcpyA(subsrc, cwd);
8507     lstrcatA(subsrc, "five");
8508     lstrcatA(subsrc, "\\");
8509
8510     /* short dir exists before FileCost */
8511     size = MAX_PATH;
8512     lstrcpyA(path, "kiwi");
8513     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
8514     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8515     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8516     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8517
8518     lstrcpyA(subsrc, cwd);
8519     lstrcatA(subsrc, "seven");
8520     lstrcatA(subsrc, "\\");
8521
8522     /* long dir exists before FileCost */
8523     size = MAX_PATH;
8524     lstrcpyA(path, "kiwi");
8525     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
8526     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8527     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8528     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8529
8530     lstrcpyA(subsrc, cwd);
8531     lstrcatA(subsrc, "nine");
8532     lstrcatA(subsrc, "\\");
8533
8534     /* short dir exists before CostFinalize */
8535     size = MAX_PATH;
8536     lstrcpyA(path, "kiwi");
8537     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
8538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8539     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8540     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8541
8542     lstrcpyA(subsrc, cwd);
8543     lstrcatA(subsrc, "eleven");
8544     lstrcatA(subsrc, "\\");
8545
8546     /* long dir exists before CostFinalize */
8547     size = MAX_PATH;
8548     lstrcpyA(path, "kiwi");
8549     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
8550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8551     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8552     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8553
8554     MsiCloseHandle(hpkg);
8555     RemoveDirectoryA("short");
8556     RemoveDirectoryA("long");
8557     RemoveDirectoryA("one");
8558     RemoveDirectoryA("four");
8559     RemoveDirectoryA("five");
8560     RemoveDirectoryA("eight");
8561     RemoveDirectoryA("nine");
8562     RemoveDirectoryA("twelve");
8563     DeleteFileA(msifile);
8564 }
8565
8566 static void test_sourcedir(void)
8567 {
8568     MSIHANDLE hdb, hpkg;
8569     CHAR package[10];
8570     CHAR path[MAX_PATH];
8571     CHAR cwd[MAX_PATH];
8572     CHAR subsrc[MAX_PATH];
8573     DWORD size;
8574     UINT r;
8575
8576     lstrcpyA(cwd, CURR_DIR);
8577     lstrcatA(cwd, "\\");
8578
8579     lstrcpyA(subsrc, cwd);
8580     lstrcatA(subsrc, "long");
8581     lstrcatA(subsrc, "\\");
8582
8583     hdb = create_package_db();
8584     ok( hdb, "failed to create database\n");
8585
8586     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
8587     ok(r == S_OK, "failed\n");
8588
8589     sprintf(package, "#%li", hdb);
8590     r = MsiOpenPackage(package, &hpkg);
8591     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8592
8593     /* properties only */
8594
8595     /* SourceDir prop */
8596     size = MAX_PATH;
8597     lstrcpyA(path, "kiwi");
8598     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8599     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8600     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8601     ok(size == 0, "Expected 0, got %d\n", size);
8602
8603     /* SOURCEDIR prop */
8604     size = MAX_PATH;
8605     lstrcpyA(path, "kiwi");
8606     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8608     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8609     ok(size == 0, "Expected 0, got %d\n", size);
8610
8611     r = MsiDoAction(hpkg, "CostInitialize");
8612     ok(r == ERROR_SUCCESS, "file cost failed\n");
8613
8614     /* SourceDir after CostInitialize */
8615     size = MAX_PATH;
8616     lstrcpyA(path, "kiwi");
8617     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8618     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8619     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8620     ok(size == 0, "Expected 0, got %d\n", size);
8621
8622     /* SOURCEDIR after CostInitialize */
8623     size = MAX_PATH;
8624     lstrcpyA(path, "kiwi");
8625     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8626     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8627     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8628     ok(size == 0, "Expected 0, got %d\n", size);
8629
8630     r = MsiDoAction(hpkg, "FileCost");
8631     ok(r == ERROR_SUCCESS, "file cost failed\n");
8632
8633     /* SourceDir after FileCost */
8634     size = MAX_PATH;
8635     lstrcpyA(path, "kiwi");
8636     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8637     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8638     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8639     ok(size == 0, "Expected 0, got %d\n", size);
8640
8641     /* SOURCEDIR after FileCost */
8642     size = MAX_PATH;
8643     lstrcpyA(path, "kiwi");
8644     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8645     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8646     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8647     ok(size == 0, "Expected 0, got %d\n", size);
8648
8649     r = MsiDoAction(hpkg, "CostFinalize");
8650     ok(r == ERROR_SUCCESS, "file cost failed\n");
8651
8652     /* SourceDir after CostFinalize */
8653     size = MAX_PATH;
8654     lstrcpyA(path, "kiwi");
8655     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8656     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8657     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8658     ok(size == 0, "Expected 0, got %d\n", size);
8659
8660     /* SOURCEDIR after CostFinalize */
8661     size = MAX_PATH;
8662     lstrcpyA(path, "kiwi");
8663     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8665     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8666     ok(size == 0, "Expected 0, got %d\n", size);
8667
8668     r = MsiDoAction(hpkg, "ResolveSource");
8669     ok(r == ERROR_SUCCESS, "file cost failed\n");
8670
8671     /* SourceDir after ResolveSource */
8672     size = MAX_PATH;
8673     lstrcpyA(path, "kiwi");
8674     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8675     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8676     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8677     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8678
8679     /* SOURCEDIR after ResolveSource */
8680     size = MAX_PATH;
8681     lstrcpyA(path, "kiwi");
8682     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8683     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8684     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8685     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8686
8687     /* random casing */
8688     size = MAX_PATH;
8689     lstrcpyA(path, "kiwi");
8690     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
8691     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8692     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8693     ok(size == 0, "Expected 0, got %d\n", size);
8694
8695     MsiCloseHandle(hpkg);
8696
8697     /* reset the package state */
8698     sprintf(package, "#%li", hdb);
8699     r = MsiOpenPackage(package, &hpkg);
8700     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8701
8702     /* test how MsiGetSourcePath affects the properties */
8703
8704     /* SourceDir prop */
8705     size = MAX_PATH;
8706     lstrcpyA(path, "kiwi");
8707     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8708     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8709     todo_wine
8710     {
8711         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8712         ok(size == 0, "Expected 0, got %d\n", size);
8713     }
8714
8715     size = MAX_PATH;
8716     lstrcpyA(path, "kiwi");
8717     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8718     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8719     ok(!lstrcmpA(path, "kiwi"),
8720        "Expected path to be unchanged, got \"%s\"\n", path);
8721     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8722
8723     /* SourceDir after MsiGetSourcePath */
8724     size = MAX_PATH;
8725     lstrcpyA(path, "kiwi");
8726     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8727     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8728     todo_wine
8729     {
8730         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8731         ok(size == 0, "Expected 0, got %d\n", size);
8732     }
8733
8734     /* SOURCEDIR prop */
8735     size = MAX_PATH;
8736     lstrcpyA(path, "kiwi");
8737     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8738     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8739     todo_wine
8740     {
8741         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8742         ok(size == 0, "Expected 0, got %d\n", size);
8743     }
8744
8745     size = MAX_PATH;
8746     lstrcpyA(path, "kiwi");
8747     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8748     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8749     ok(!lstrcmpA(path, "kiwi"),
8750        "Expected path to be unchanged, got \"%s\"\n", path);
8751     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8752
8753     /* SOURCEDIR prop after MsiGetSourcePath */
8754     size = MAX_PATH;
8755     lstrcpyA(path, "kiwi");
8756     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8757     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8758     todo_wine
8759     {
8760         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8761         ok(size == 0, "Expected 0, got %d\n", size);
8762     }
8763
8764     r = MsiDoAction(hpkg, "CostInitialize");
8765     ok(r == ERROR_SUCCESS, "file cost failed\n");
8766
8767     /* SourceDir after CostInitialize */
8768     size = MAX_PATH;
8769     lstrcpyA(path, "kiwi");
8770     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8772     todo_wine
8773     {
8774         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8775         ok(size == 0, "Expected 0, got %d\n", size);
8776     }
8777
8778     size = MAX_PATH;
8779     lstrcpyA(path, "kiwi");
8780     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8781     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8782     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8783     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8784
8785     /* SourceDir after MsiGetSourcePath */
8786     size = MAX_PATH;
8787     lstrcpyA(path, "kiwi");
8788     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8790     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8791     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8792
8793     /* SOURCEDIR after CostInitialize */
8794     size = MAX_PATH;
8795     lstrcpyA(path, "kiwi");
8796     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8797     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8798     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8799     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8800
8801     /* SOURCEDIR source path still does not exist */
8802     size = MAX_PATH;
8803     lstrcpyA(path, "kiwi");
8804     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8805     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8806     ok(!lstrcmpA(path, "kiwi"),
8807        "Expected path to be unchanged, got \"%s\"\n", path);
8808     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8809
8810     r = MsiDoAction(hpkg, "FileCost");
8811     ok(r == ERROR_SUCCESS, "file cost failed\n");
8812
8813     /* SourceDir after FileCost */
8814     size = MAX_PATH;
8815     lstrcpyA(path, "kiwi");
8816     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8817     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8818     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8819     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8820
8821     /* SOURCEDIR after FileCost */
8822     size = MAX_PATH;
8823     lstrcpyA(path, "kiwi");
8824     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8826     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8827     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8828
8829     /* SOURCEDIR source path still does not exist */
8830     size = MAX_PATH;
8831     lstrcpyA(path, "kiwi");
8832     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8833     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8834     ok(!lstrcmpA(path, "kiwi"),
8835        "Expected path to be unchanged, got \"%s\"\n", path);
8836     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8837
8838     r = MsiDoAction(hpkg, "CostFinalize");
8839     ok(r == ERROR_SUCCESS, "file cost failed\n");
8840
8841     /* SourceDir after CostFinalize */
8842     size = MAX_PATH;
8843     lstrcpyA(path, "kiwi");
8844     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8845     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8846     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8847     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8848
8849     /* SOURCEDIR after CostFinalize */
8850     size = MAX_PATH;
8851     lstrcpyA(path, "kiwi");
8852     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8853     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8854     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8855     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8856
8857     /* SOURCEDIR source path still does not exist */
8858     size = MAX_PATH;
8859     lstrcpyA(path, "kiwi");
8860     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8861     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8862     ok(!lstrcmpA(path, "kiwi"),
8863        "Expected path to be unchanged, got \"%s\"\n", path);
8864     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8865
8866     r = MsiDoAction(hpkg, "ResolveSource");
8867     ok(r == ERROR_SUCCESS, "file cost failed\n");
8868
8869     /* SourceDir after ResolveSource */
8870     size = MAX_PATH;
8871     lstrcpyA(path, "kiwi");
8872     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8874     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8875     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8876
8877     /* SOURCEDIR after ResolveSource */
8878     size = MAX_PATH;
8879     lstrcpyA(path, "kiwi");
8880     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8881     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8882     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8883     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8884
8885     /* SOURCEDIR source path still does not exist */
8886     size = MAX_PATH;
8887     lstrcpyA(path, "kiwi");
8888     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8889     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8890     ok(!lstrcmpA(path, "kiwi"),
8891        "Expected path to be unchanged, got \"%s\"\n", path);
8892     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8893
8894     MsiCloseHandle(hdb);
8895     MsiCloseHandle(hpkg);
8896     DeleteFileA(msifile);
8897 }
8898
8899 struct access_res
8900 {
8901     BOOL gothandle;
8902     DWORD lasterr;
8903     BOOL ignore;
8904 };
8905
8906 static const struct access_res create[16] =
8907 {
8908     { TRUE, ERROR_SUCCESS, TRUE },
8909     { TRUE, ERROR_SUCCESS, TRUE },
8910     { TRUE, ERROR_SUCCESS, FALSE },
8911     { TRUE, ERROR_SUCCESS, FALSE },
8912     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8913     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8914     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8915     { TRUE, ERROR_SUCCESS, FALSE },
8916     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8917     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8918     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8919     { TRUE, ERROR_SUCCESS, TRUE },
8920     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8921     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8922     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8923     { TRUE, ERROR_SUCCESS, TRUE }
8924 };
8925
8926 static const struct access_res create_commit[16] =
8927 {
8928     { TRUE, ERROR_SUCCESS, TRUE },
8929     { TRUE, ERROR_SUCCESS, TRUE },
8930     { TRUE, ERROR_SUCCESS, FALSE },
8931     { TRUE, ERROR_SUCCESS, FALSE },
8932     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8933     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8934     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8935     { TRUE, ERROR_SUCCESS, FALSE },
8936     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8937     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8938     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8939     { TRUE, ERROR_SUCCESS, TRUE },
8940     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8941     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8942     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8943     { TRUE, ERROR_SUCCESS, TRUE }
8944 };
8945
8946 static const struct access_res create_close[16] =
8947 {
8948     { TRUE, ERROR_SUCCESS, FALSE },
8949     { TRUE, ERROR_SUCCESS, FALSE },
8950     { TRUE, ERROR_SUCCESS, FALSE },
8951     { TRUE, ERROR_SUCCESS, FALSE },
8952     { TRUE, ERROR_SUCCESS, FALSE },
8953     { TRUE, ERROR_SUCCESS, FALSE },
8954     { TRUE, ERROR_SUCCESS, FALSE },
8955     { TRUE, ERROR_SUCCESS, FALSE },
8956     { TRUE, ERROR_SUCCESS, FALSE },
8957     { TRUE, ERROR_SUCCESS, FALSE },
8958     { TRUE, ERROR_SUCCESS, FALSE },
8959     { TRUE, ERROR_SUCCESS, FALSE },
8960     { TRUE, ERROR_SUCCESS, FALSE },
8961     { TRUE, ERROR_SUCCESS, FALSE },
8962     { TRUE, ERROR_SUCCESS, FALSE },
8963     { TRUE, ERROR_SUCCESS }
8964 };
8965
8966 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
8967 {
8968     DWORD access = 0, share = 0;
8969     DWORD lasterr;
8970     HANDLE hfile;
8971     int i, j, idx = 0;
8972
8973     for (i = 0; i < 4; i++)
8974     {
8975         if (i == 0) access = 0;
8976         if (i == 1) access = GENERIC_READ;
8977         if (i == 2) access = GENERIC_WRITE;
8978         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
8979
8980         for (j = 0; j < 4; j++)
8981         {
8982             if (ares[idx].ignore)
8983                 continue;
8984
8985             if (j == 0) share = 0;
8986             if (j == 1) share = FILE_SHARE_READ;
8987             if (j == 2) share = FILE_SHARE_WRITE;
8988             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
8989
8990             SetLastError(0xdeadbeef);
8991             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
8992                                 FILE_ATTRIBUTE_NORMAL, 0);
8993             lasterr = GetLastError();
8994
8995             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
8996                "(%d, handle, %d): Expected %d, got %d\n",
8997                line, idx, ares[idx].gothandle,
8998                (hfile != INVALID_HANDLE_VALUE));
8999
9000             ok(lasterr == ares[idx].lasterr ||
9001                lasterr == 0xdeadbeef, /* win9x */
9002                "(%d, lasterr, %d): Expected %d, got %d\n",
9003                line, idx, ares[idx].lasterr, lasterr);
9004
9005             CloseHandle(hfile);
9006             idx++;
9007         }
9008     }
9009 }
9010
9011 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
9012
9013 static void test_access(void)
9014 {
9015     MSIHANDLE hdb;
9016     UINT r;
9017
9018     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
9019     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9020
9021     test_file_access(msifile, create);
9022
9023     r = MsiDatabaseCommit(hdb);
9024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9025
9026     test_file_access(msifile, create_commit);
9027
9028     MsiCloseHandle(hdb);
9029
9030     test_file_access(msifile, create_close);
9031
9032     DeleteFileA(msifile);
9033
9034     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
9035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9036
9037     test_file_access(msifile, create);
9038
9039     r = MsiDatabaseCommit(hdb);
9040     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9041
9042     test_file_access(msifile, create_commit);
9043
9044     MsiCloseHandle(hdb);
9045
9046     test_file_access(msifile, create_close);
9047
9048     DeleteFileA(msifile);
9049 }
9050
9051 static void test_emptypackage(void)
9052 {
9053     MSIHANDLE hpkg, hdb, hsuminfo;
9054     MSIHANDLE hview, hrec;
9055     MSICONDITION condition;
9056     CHAR buffer[MAX_PATH];
9057     DWORD size;
9058     UINT r;
9059
9060     r = MsiOpenPackageA("", &hpkg);
9061     todo_wine
9062     {
9063         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9064     }
9065
9066     hdb = MsiGetActiveDatabase(hpkg);
9067     todo_wine
9068     {
9069         ok(hdb != 0, "Expected a valid database handle\n");
9070     }
9071
9072     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
9073     todo_wine
9074     {
9075         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9076     }
9077     r = MsiViewExecute(hview, 0);
9078     todo_wine
9079     {
9080         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9081     }
9082
9083     r = MsiViewFetch(hview, &hrec);
9084     todo_wine
9085     {
9086         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9087     }
9088
9089     size = MAX_PATH;
9090     r = MsiRecordGetString(hrec, 1, buffer, &size);
9091     todo_wine
9092     {
9093         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9094         ok(!lstrcmpA(buffer, "_Property"),
9095            "Expected \"_Property\", got \"%s\"\n", buffer);
9096     }
9097
9098     MsiCloseHandle(hrec);
9099
9100     r = MsiViewFetch(hview, &hrec);
9101     todo_wine
9102     {
9103         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9104     }
9105
9106     size = MAX_PATH;
9107     r = MsiRecordGetString(hrec, 1, buffer, &size);
9108     todo_wine
9109     {
9110         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9111         ok(!lstrcmpA(buffer, "#_FolderCache"),
9112            "Expected \"_Property\", got \"%s\"\n", buffer);
9113     }
9114
9115     MsiCloseHandle(hrec);
9116     MsiViewClose(hview);
9117     MsiCloseHandle(hview);
9118
9119     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
9120     todo_wine
9121     {
9122         ok(condition == MSICONDITION_FALSE,
9123            "Expected MSICONDITION_FALSE, got %d\n", condition);
9124     }
9125
9126     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
9127     todo_wine
9128     {
9129         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9130     }
9131     r = MsiViewExecute(hview, 0);
9132     todo_wine
9133     {
9134         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9135     }
9136
9137     /* _Property table is not empty */
9138     r = MsiViewFetch(hview, &hrec);
9139     todo_wine
9140     {
9141         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9142     }
9143
9144     MsiCloseHandle(hrec);
9145     MsiViewClose(hview);
9146     MsiCloseHandle(hview);
9147
9148     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
9149     todo_wine
9150     {
9151         ok(condition == MSICONDITION_FALSE,
9152            "Expected MSICONDITION_FALSE, got %d\n", condition);
9153     }
9154
9155     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
9156     todo_wine
9157     {
9158         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9159     }
9160     r = MsiViewExecute(hview, 0);
9161     todo_wine
9162     {
9163         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9164     }
9165
9166     /* #_FolderCache is not empty */
9167     r = MsiViewFetch(hview, &hrec);
9168     todo_wine
9169     {
9170         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9171     }
9172
9173     MsiCloseHandle(hrec);
9174     MsiViewClose(hview);
9175     MsiCloseHandle(hview);
9176
9177     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
9178     todo_wine
9179     {
9180         ok(r == ERROR_BAD_QUERY_SYNTAX,
9181            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
9182     }
9183
9184     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
9185     todo_wine
9186     {
9187         ok(r == ERROR_BAD_QUERY_SYNTAX,
9188            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
9189     }
9190
9191     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
9192     todo_wine
9193     {
9194         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
9195            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
9196     }
9197
9198     MsiCloseHandle(hsuminfo);
9199
9200     r = MsiDatabaseCommit(hdb);
9201     todo_wine
9202     {
9203         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9204     }
9205
9206     MsiCloseHandle(hdb);
9207     MsiCloseHandle(hpkg);
9208 }
9209
9210 START_TEST(package)
9211 {
9212     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
9213
9214     test_createpackage();
9215     test_doaction();
9216     test_gettargetpath_bad();
9217     test_settargetpath();
9218     test_props();
9219     test_property_table();
9220     test_condition();
9221     test_msipackage();
9222     test_formatrecord2();
9223     test_states();
9224     test_getproperty();
9225     test_removefiles();
9226     test_appsearch();
9227     test_appsearch_complocator();
9228     test_appsearch_reglocator();
9229     test_appsearch_inilocator();
9230     test_appsearch_drlocator();
9231     test_featureparents();
9232     test_installprops();
9233     test_launchconditions();
9234     test_ccpsearch();
9235     test_complocator();
9236     test_MsiGetSourcePath();
9237     test_shortlongsource();
9238     test_sourcedir();
9239     test_access();
9240     test_emptypackage();
9241 }