fltlib: Add a stub dll.
[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 #include <srrestoreptapi.h>
30
31 #include "wine/test.h"
32
33 static const char msifile[] = "winetest.msi";
34 char CURR_DIR[MAX_PATH];
35
36 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
37
38 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
39
40 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
41 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
42
43 static void init_functionpointers(void)
44 {
45     HMODULE hmsi = GetModuleHandleA("msi.dll");
46     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
47     HMODULE hsrclient;
48
49 #define GET_PROC(mod, func) \
50     p ## func = (void*)GetProcAddress(mod, #func);
51
52     GET_PROC(hmsi, MsiApplyMultiplePatchesA);
53
54     GET_PROC(hadvapi32, ConvertSidToStringSidA);
55
56     hsrclient = LoadLibraryA("srclient.dll");
57     GET_PROC(hsrclient, SRRemoveRestorePoint);
58     GET_PROC(hsrclient, SRSetRestorePointA);
59 #undef GET_PROC
60 }
61
62
63 static LPSTR get_user_sid(LPSTR *usersid)
64 {
65     HANDLE token;
66     BYTE buf[1024];
67     DWORD size;
68     PTOKEN_USER user;
69
70     if (!pConvertSidToStringSidA)
71     {
72         win_skip("ConvertSidToStringSidA is not available\n");
73         return NULL;
74     }
75
76     *usersid = NULL;
77     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
78     size = sizeof(buf);
79     GetTokenInformation(token, TokenUser, buf, size, &size);
80     user = (PTOKEN_USER)buf;
81     pConvertSidToStringSidA(user->User.Sid, usersid);
82     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
83     CloseHandle(token);
84     return *usersid;
85 }
86
87 /* RegDeleteTreeW from dlls/advapi32/registry.c */
88 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
89 {
90     LONG ret;
91     DWORD dwMaxSubkeyLen, dwMaxValueLen;
92     DWORD dwMaxLen, dwSize;
93     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
94     HKEY hSubKey = hKey;
95
96     if(lpszSubKey)
97     {
98         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
99         if (ret) return ret;
100     }
101
102     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
103             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
104     if (ret) goto cleanup;
105
106     dwMaxSubkeyLen++;
107     dwMaxValueLen++;
108     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
109     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
110     {
111         /* Name too big: alloc a buffer for it */
112         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
113         {
114             ret = ERROR_NOT_ENOUGH_MEMORY;
115             goto cleanup;
116         }
117     }
118
119     /* Recursively delete all the subkeys */
120     while (TRUE)
121     {
122         dwSize = dwMaxLen;
123         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
124                           NULL, NULL, NULL)) break;
125
126         ret = package_RegDeleteTreeW(hSubKey, lpszName);
127         if (ret) goto cleanup;
128     }
129
130     if (lpszSubKey)
131         ret = RegDeleteKeyW(hKey, lpszSubKey);
132     else
133         while (TRUE)
134         {
135             dwSize = dwMaxLen;
136             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
137                   NULL, NULL, NULL, NULL)) break;
138
139             ret = RegDeleteValueW(hKey, lpszName);
140             if (ret) goto cleanup;
141         }
142
143 cleanup:
144     if (lpszName != szNameBuf)
145         HeapFree(GetProcessHeap(), 0, lpszName);
146     if(lpszSubKey)
147         RegCloseKey(hSubKey);
148     return ret;
149 }
150
151 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
152 {
153     DWORD i,n=1;
154     GUID guid;
155
156     if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
157         return FALSE;
158
159     for(i=0; i<8; i++)
160         out[7-i] = in[n++];
161     n++;
162     for(i=0; i<4; i++)
163         out[11-i] = in[n++];
164     n++;
165     for(i=0; i<4; i++)
166         out[15-i] = in[n++];
167     n++;
168     for(i=0; i<2; i++)
169     {
170         out[17+i*2] = in[n++];
171         out[16+i*2] = in[n++];
172     }
173     n++;
174     for( ; i<8; i++)
175     {
176         out[17+i*2] = in[n++];
177         out[16+i*2] = in[n++];
178     }
179     out[32]=0;
180     return TRUE;
181 }
182
183 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
184 {
185     WCHAR guidW[MAX_PATH];
186     WCHAR squashedW[MAX_PATH];
187     GUID guid;
188     HRESULT hr;
189     int size;
190
191     hr = CoCreateGuid(&guid);
192     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
193
194     size = StringFromGUID2(&guid, guidW, MAX_PATH);
195     ok(size == 39, "Expected 39, got %d\n", hr);
196
197     WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
198     squash_guid(guidW, squashedW);
199     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
200 }
201
202 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
203                                LPCSTR guid, LPSTR usersid, BOOL dir)
204 {
205     WCHAR guidW[MAX_PATH];
206     WCHAR squashedW[MAX_PATH];
207     CHAR squashed[MAX_PATH];
208     CHAR comppath[MAX_PATH];
209     CHAR prodpath[MAX_PATH];
210     CHAR path[MAX_PATH];
211     LPCSTR prod = NULL;
212     HKEY hkey;
213
214     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
215     squash_guid(guidW, squashedW);
216     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
217
218     if (context == MSIINSTALLCONTEXT_MACHINE)
219     {
220         prod = "3D0DAE300FACA1300AD792060BCDAA92";
221         sprintf(comppath,
222                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
223                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
224         lstrcpyA(prodpath,
225                  "SOFTWARE\\Classes\\Installer\\"
226                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
227     }
228     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
229     {
230         prod = "7D2F387510109040002000060BECB6AB";
231         sprintf(comppath,
232                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
233                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
234         sprintf(prodpath,
235                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
236                 "Installer\\%s\\Installer\\Products\\"
237                 "7D2F387510109040002000060BECB6AB", usersid);
238     }
239     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
240     {
241         prod = "7D2F387510109040002000060BECB6AB";
242         sprintf(comppath,
243                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
244                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
245         sprintf(prodpath,
246                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
247                 "Installer\\Managed\\%s\\Installer\\Products\\"
248                 "7D2F387510109040002000060BECB6AB", usersid);
249     }
250
251     RegCreateKeyA(HKEY_LOCAL_MACHINE, comppath, &hkey);
252
253     lstrcpyA(path, CURR_DIR);
254     lstrcatA(path, "\\");
255     if (!dir) lstrcatA(path, filename);
256
257     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
258     RegCloseKey(hkey);
259
260     RegCreateKeyA(HKEY_LOCAL_MACHINE, prodpath, &hkey);
261     RegCloseKey(hkey);
262 }
263
264 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
265 {
266     WCHAR guidW[MAX_PATH];
267     WCHAR squashedW[MAX_PATH];
268     WCHAR substrW[MAX_PATH];
269     CHAR squashed[MAX_PATH];
270     CHAR comppath[MAX_PATH];
271     CHAR prodpath[MAX_PATH];
272
273     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
274     squash_guid(guidW, squashedW);
275     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
276
277     if (context == MSIINSTALLCONTEXT_MACHINE)
278     {
279         sprintf(comppath,
280                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
281                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
282         lstrcpyA(prodpath,
283                  "SOFTWARE\\Classes\\Installer\\"
284                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
285     }
286     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
287     {
288         sprintf(comppath,
289                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
290                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
291         sprintf(prodpath,
292                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
293                 "Installer\\%s\\Installer\\Products\\"
294                 "7D2F387510109040002000060BECB6AB", usersid);
295     }
296     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
297     {
298         sprintf(comppath,
299                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
300                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
301         sprintf(prodpath,
302                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
303                 "Installer\\Managed\\%s\\Installer\\Products\\"
304                 "7D2F387510109040002000060BECB6AB", usersid);
305     }
306
307     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
308     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
309
310     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
311     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
312 }
313
314 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
315 {
316     MSIHANDLE hview = 0;
317     UINT r, ret;
318
319     /* open a select query */
320     r = MsiDatabaseOpenView(hdb, query, &hview);
321     if (r != ERROR_SUCCESS)
322         return r;
323     r = MsiViewExecute(hview, 0);
324     if (r != ERROR_SUCCESS)
325         return r;
326     ret = MsiViewFetch(hview, phrec);
327     r = MsiViewClose(hview);
328     if (r != ERROR_SUCCESS)
329         return r;
330     r = MsiCloseHandle(hview);
331     if (r != ERROR_SUCCESS)
332         return r;
333     return ret;
334 }
335
336 static UINT run_query( MSIHANDLE hdb, const char *query )
337 {
338     MSIHANDLE hview = 0;
339     UINT r;
340
341     r = MsiDatabaseOpenView(hdb, query, &hview);
342     if( r != ERROR_SUCCESS )
343         return r;
344
345     r = MsiViewExecute(hview, 0);
346     if( r == ERROR_SUCCESS )
347         r = MsiViewClose(hview);
348     MsiCloseHandle(hview);
349     return r;
350 }
351
352 static UINT create_component_table( MSIHANDLE hdb )
353 {
354     return run_query( hdb,
355             "CREATE TABLE `Component` ( "
356             "`Component` CHAR(72) NOT NULL, "
357             "`ComponentId` CHAR(38), "
358             "`Directory_` CHAR(72) NOT NULL, "
359             "`Attributes` SHORT NOT NULL, "
360             "`Condition` CHAR(255), "
361             "`KeyPath` CHAR(72) "
362             "PRIMARY KEY `Component`)" );
363 }
364
365 static UINT create_feature_table( MSIHANDLE hdb )
366 {
367     return run_query( hdb,
368             "CREATE TABLE `Feature` ( "
369             "`Feature` CHAR(38) NOT NULL, "
370             "`Feature_Parent` CHAR(38), "
371             "`Title` CHAR(64), "
372             "`Description` CHAR(255), "
373             "`Display` SHORT NOT NULL, "
374             "`Level` SHORT NOT NULL, "
375             "`Directory_` CHAR(72), "
376             "`Attributes` SHORT NOT NULL "
377             "PRIMARY KEY `Feature`)" );
378 }
379
380 static UINT create_feature_components_table( MSIHANDLE hdb )
381 {
382     return run_query( hdb,
383             "CREATE TABLE `FeatureComponents` ( "
384             "`Feature_` CHAR(38) NOT NULL, "
385             "`Component_` CHAR(72) NOT NULL "
386             "PRIMARY KEY `Feature_`, `Component_` )" );
387 }
388
389 static UINT create_file_table( MSIHANDLE hdb )
390 {
391     return run_query( hdb,
392             "CREATE TABLE `File` ("
393             "`File` CHAR(72) NOT NULL, "
394             "`Component_` CHAR(72) NOT NULL, "
395             "`FileName` CHAR(255) NOT NULL, "
396             "`FileSize` LONG NOT NULL, "
397             "`Version` CHAR(72), "
398             "`Language` CHAR(20), "
399             "`Attributes` SHORT, "
400             "`Sequence` SHORT NOT NULL "
401             "PRIMARY KEY `File`)" );
402 }
403
404 static UINT create_remove_file_table( MSIHANDLE hdb )
405 {
406     return run_query( hdb,
407             "CREATE TABLE `RemoveFile` ("
408             "`FileKey` CHAR(72) NOT NULL, "
409             "`Component_` CHAR(72) NOT NULL, "
410             "`FileName` CHAR(255) LOCALIZABLE, "
411             "`DirProperty` CHAR(72) NOT NULL, "
412             "`InstallMode` SHORT NOT NULL "
413             "PRIMARY KEY `FileKey`)" );
414 }
415
416 static UINT create_appsearch_table( MSIHANDLE hdb )
417 {
418     return run_query( hdb,
419             "CREATE TABLE `AppSearch` ("
420             "`Property` CHAR(72) NOT NULL, "
421             "`Signature_` CHAR(72) NOT NULL "
422             "PRIMARY KEY `Property`, `Signature_`)" );
423 }
424
425 static UINT create_reglocator_table( MSIHANDLE hdb )
426 {
427     return run_query( hdb,
428             "CREATE TABLE `RegLocator` ("
429             "`Signature_` CHAR(72) NOT NULL, "
430             "`Root` SHORT NOT NULL, "
431             "`Key` CHAR(255) NOT NULL, "
432             "`Name` CHAR(255), "
433             "`Type` SHORT "
434             "PRIMARY KEY `Signature_`)" );
435 }
436
437 static UINT create_signature_table( MSIHANDLE hdb )
438 {
439     return run_query( hdb,
440             "CREATE TABLE `Signature` ("
441             "`Signature` CHAR(72) NOT NULL, "
442             "`FileName` CHAR(255) NOT NULL, "
443             "`MinVersion` CHAR(20), "
444             "`MaxVersion` CHAR(20), "
445             "`MinSize` LONG, "
446             "`MaxSize` LONG, "
447             "`MinDate` LONG, "
448             "`MaxDate` LONG, "
449             "`Languages` CHAR(255) "
450             "PRIMARY KEY `Signature`)" );
451 }
452
453 static UINT create_launchcondition_table( MSIHANDLE hdb )
454 {
455     return run_query( hdb,
456             "CREATE TABLE `LaunchCondition` ("
457             "`Condition` CHAR(255) NOT NULL, "
458             "`Description` CHAR(255) NOT NULL "
459             "PRIMARY KEY `Condition`)" );
460 }
461
462 static UINT create_property_table( MSIHANDLE hdb )
463 {
464     return run_query( hdb,
465             "CREATE TABLE `Property` ("
466             "`Property` CHAR(72) NOT NULL, "
467             "`Value` CHAR(0) "
468             "PRIMARY KEY `Property`)" );
469 }
470
471 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
472 {
473     return run_query( hdb,
474             "CREATE TABLE `InstallExecuteSequence` ("
475             "`Action` CHAR(72) NOT NULL, "
476             "`Condition` CHAR(255), "
477             "`Sequence` SHORT "
478             "PRIMARY KEY `Action`)" );
479 }
480
481 static UINT create_media_table( MSIHANDLE hdb )
482 {
483     return run_query( hdb,
484             "CREATE TABLE `Media` ("
485             "`DiskId` SHORT NOT NULL, "
486             "`LastSequence` SHORT NOT NULL, "
487             "`DiskPrompt` CHAR(64), "
488             "`Cabinet` CHAR(255), "
489             "`VolumeLabel` CHAR(32), "
490             "`Source` CHAR(72) "
491             "PRIMARY KEY `DiskId`)" );
492 }
493
494 static UINT create_ccpsearch_table( MSIHANDLE hdb )
495 {
496     return run_query( hdb,
497             "CREATE TABLE `CCPSearch` ("
498             "`Signature_` CHAR(72) NOT NULL "
499             "PRIMARY KEY `Signature_`)" );
500 }
501
502 static UINT create_drlocator_table( MSIHANDLE hdb )
503 {
504     return run_query( hdb,
505             "CREATE TABLE `DrLocator` ("
506             "`Signature_` CHAR(72) NOT NULL, "
507             "`Parent` CHAR(72), "
508             "`Path` CHAR(255), "
509             "`Depth` SHORT "
510             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
511 }
512
513 static UINT create_complocator_table( MSIHANDLE hdb )
514 {
515     return run_query( hdb,
516             "CREATE TABLE `CompLocator` ("
517             "`Signature_` CHAR(72) NOT NULL, "
518             "`ComponentId` CHAR(38) NOT NULL, "
519             "`Type` SHORT "
520             "PRIMARY KEY `Signature_`)" );
521 }
522
523 static UINT create_inilocator_table( MSIHANDLE hdb )
524 {
525     return run_query( hdb,
526             "CREATE TABLE `IniLocator` ("
527             "`Signature_` CHAR(72) NOT NULL, "
528             "`FileName` CHAR(255) NOT NULL, "
529             "`Section` CHAR(96)NOT NULL, "
530             "`Key` CHAR(128)NOT NULL, "
531             "`Field` SHORT, "
532             "`Type` SHORT "
533             "PRIMARY KEY `Signature_`)" );
534 }
535
536 #define make_add_entry(type, qtext) \
537     static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
538     { \
539         char insert[] = qtext; \
540         char *query; \
541         UINT sz, r; \
542         sz = strlen(values) + sizeof insert; \
543         query = HeapAlloc(GetProcessHeap(),0,sz); \
544         sprintf(query,insert,values); \
545         r = run_query( hdb, query ); \
546         HeapFree(GetProcessHeap(), 0, query); \
547         return r; \
548     }
549
550 make_add_entry(component,
551                "INSERT INTO `Component`  "
552                "(`Component`, `ComponentId`, `Directory_`, "
553                "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
554
555 make_add_entry(directory,
556                "INSERT INTO `Directory` "
557                "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
558
559 make_add_entry(feature,
560                "INSERT INTO `Feature` "
561                "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
562                "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
563
564 make_add_entry(feature_components,
565                "INSERT INTO `FeatureComponents` "
566                "(`Feature_`, `Component_`) VALUES( %s )")
567
568 make_add_entry(file,
569                "INSERT INTO `File` "
570                "(`File`, `Component_`, `FileName`, `FileSize`, "
571                "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
572
573 make_add_entry(appsearch,
574                "INSERT INTO `AppSearch` "
575                "(`Property`, `Signature_`) VALUES( %s )")
576
577 make_add_entry(reglocator,
578                "INSERT INTO `RegLocator` "
579                "(`Signature_`, `Root`, `Key`, `Name`, `Type`) VALUES( %s )")
580
581 make_add_entry(signature,
582                "INSERT INTO `Signature` "
583                "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
584                " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
585                "VALUES( %s )")
586
587 make_add_entry(launchcondition,
588                "INSERT INTO `LaunchCondition` "
589                "(`Condition`, `Description`) VALUES( %s )")
590
591 make_add_entry(property,
592                "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
593
594 make_add_entry(install_execute_sequence,
595                "INSERT INTO `InstallExecuteSequence` "
596                "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
597
598 make_add_entry(media,
599                "INSERT INTO `Media` "
600                "(`DiskId`, `LastSequence`, `DiskPrompt`, "
601                "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
602
603 make_add_entry(ccpsearch,
604                "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
605
606 make_add_entry(drlocator,
607                "INSERT INTO `DrLocator` "
608                "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
609
610 make_add_entry(complocator,
611                "INSERT INTO `CompLocator` "
612                "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
613
614 make_add_entry(inilocator,
615                "INSERT INTO `IniLocator` "
616                "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
617                "VALUES( %s )")
618
619 static UINT set_summary_info(MSIHANDLE hdb)
620 {
621     UINT res;
622     MSIHANDLE suminfo;
623
624     /* build summary info */
625     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
626     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
627
628     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
629                         "Installation Database");
630     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
631
632     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
633                         "Installation Database");
634     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
635
636     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
637                         "Wine Hackers");
638     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
639
640     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
641                     ";1033");
642     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
643
644     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
645                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
646     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
647
648     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
649     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
650
651     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
652     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
653
654     res = MsiSummaryInfoPersist(suminfo);
655     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
656
657     res = MsiCloseHandle( suminfo);
658     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
659
660     return res;
661 }
662
663
664 static MSIHANDLE create_package_db(void)
665 {
666     MSIHANDLE hdb = 0;
667     UINT res;
668
669     DeleteFile(msifile);
670
671     /* create an empty database */
672     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
673     ok( res == ERROR_SUCCESS , "Failed to create database\n" );
674     if( res != ERROR_SUCCESS )
675         return hdb;
676
677     res = MsiDatabaseCommit( hdb );
678     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
679
680     res = set_summary_info(hdb);
681
682     res = run_query( hdb,
683             "CREATE TABLE `Directory` ( "
684             "`Directory` CHAR(255) NOT NULL, "
685             "`Directory_Parent` CHAR(255), "
686             "`DefaultDir` CHAR(255) NOT NULL "
687             "PRIMARY KEY `Directory`)" );
688     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
689
690     return hdb;
691 }
692
693 static MSIHANDLE package_from_db(MSIHANDLE hdb)
694 {
695     UINT res;
696     CHAR szPackage[10];
697     MSIHANDLE hPackage;
698
699     sprintf(szPackage,"#%i",hdb);
700     res = MsiOpenPackage(szPackage,&hPackage);
701     if (res != ERROR_SUCCESS)
702         return 0;
703
704     res = MsiCloseHandle(hdb);
705     if (res != ERROR_SUCCESS)
706         return 0;
707
708     return hPackage;
709 }
710
711 static void create_test_file(const CHAR *name)
712 {
713     HANDLE file;
714     DWORD written;
715
716     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
717     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
718     WriteFile(file, name, strlen(name), &written, NULL);
719     WriteFile(file, "\n", strlen("\n"), &written, NULL);
720     CloseHandle(file);
721 }
722
723 typedef struct _tagVS_VERSIONINFO
724 {
725     WORD wLength;
726     WORD wValueLength;
727     WORD wType;
728     WCHAR szKey[1];
729     WORD wPadding1[1];
730     VS_FIXEDFILEINFO Value;
731     WORD wPadding2[1];
732     WORD wChildren[1];
733 } VS_VERSIONINFO;
734
735 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
736 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
737
738 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
739 {
740     VS_VERSIONINFO *pVerInfo;
741     VS_FIXEDFILEINFO *pFixedInfo;
742     LPBYTE buffer, ofs;
743     CHAR path[MAX_PATH];
744     DWORD handle, size;
745     HANDLE resource;
746     BOOL ret = FALSE;
747
748     GetSystemDirectory(path, MAX_PATH);
749     /* Some dlls can't be updated on Vista/W2K8 */
750     lstrcatA(path, "\\version.dll");
751
752     CopyFileA(path, name, FALSE);
753
754     size = GetFileVersionInfoSize(path, &handle);
755     buffer = HeapAlloc(GetProcessHeap(), 0, size);
756
757     GetFileVersionInfoA(path, 0, size, buffer);
758
759     pVerInfo = (VS_VERSIONINFO *)buffer;
760     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
761     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
762
763     pFixedInfo->dwFileVersionMS = ms;
764     pFixedInfo->dwFileVersionLS = ls;
765     pFixedInfo->dwProductVersionMS = ms;
766     pFixedInfo->dwProductVersionLS = ls;
767
768     resource = BeginUpdateResource(name, FALSE);
769     if (!resource)
770         goto done;
771
772     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
773                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
774         goto done;
775
776     if (!EndUpdateResource(resource, FALSE))
777         goto done;
778
779     ret = TRUE;
780
781 done:
782     HeapFree(GetProcessHeap(), 0, buffer);
783     return ret;
784 }
785
786 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
787 {
788     RESTOREPOINTINFOA spec;
789
790     spec.dwEventType = event_type;
791     spec.dwRestorePtType = APPLICATION_INSTALL;
792     spec.llSequenceNumber = status->llSequenceNumber;
793     lstrcpyA(spec.szDescription, "msitest restore point");
794
795     return pSRSetRestorePointA(&spec, status);
796 }
797
798 static void remove_restore_point(DWORD seq_number)
799 {
800     DWORD res;
801
802     res = pSRRemoveRestorePoint(seq_number);
803     if (res != ERROR_SUCCESS)
804         trace("Failed to remove the restore point : %08x\n", res);
805 }
806
807 static void test_createpackage(void)
808 {
809     MSIHANDLE hPackage = 0;
810     UINT res;
811
812     hPackage = package_from_db(create_package_db());
813     ok( hPackage != 0, " Failed to create package\n");
814
815     res = MsiCloseHandle( hPackage);
816     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
817     DeleteFile(msifile);
818 }
819
820 static void test_doaction( void )
821 {
822     MSIHANDLE hpkg;
823     UINT r;
824
825     r = MsiDoAction( -1, NULL );
826     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
827
828     hpkg = package_from_db(create_package_db());
829     ok( hpkg, "failed to create package\n");
830
831     r = MsiDoAction(hpkg, NULL);
832     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
833
834     r = MsiDoAction(0, "boo");
835     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
836
837     r = MsiDoAction(hpkg, "boo");
838     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
839
840     MsiCloseHandle( hpkg );
841     DeleteFile(msifile);
842 }
843
844 static void test_gettargetpath_bad(void)
845 {
846     char buffer[0x80];
847     MSIHANDLE hpkg;
848     DWORD sz;
849     UINT r;
850
851     hpkg = package_from_db(create_package_db());
852     ok( hpkg, "failed to create package\n");
853
854     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
855     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
856
857     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
858     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
859
860     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
861     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
862
863     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
864     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
865
866     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
867     ok( r == ERROR_DIRECTORY, "wrong return val\n");
868
869     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
870     ok( r == ERROR_DIRECTORY, "wrong return val\n");
871
872     MsiCloseHandle( hpkg );
873     DeleteFile(msifile);
874 }
875
876 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
877 {
878     UINT r;
879     DWORD size;
880     MSIHANDLE rec;
881
882     rec = MsiCreateRecord( 1 );
883     ok(rec, "MsiCreate record failed\n");
884
885     r = MsiRecordSetString( rec, 0, file );
886     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
887
888     size = MAX_PATH;
889     r = MsiFormatRecord( hpkg, rec, buff, &size );
890     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
891
892     MsiCloseHandle( rec );
893 }
894
895 static void test_settargetpath(void)
896 {
897     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
898     DWORD sz;
899     MSIHANDLE hpkg;
900     UINT r;
901     MSIHANDLE hdb;
902
903     hdb = create_package_db();
904     ok ( hdb, "failed to create package database\n" );
905
906     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
907     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
908
909     r = create_component_table( hdb );
910     ok( r == S_OK, "cannot create Component table: %d\n", r );
911
912     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
913     ok( r == S_OK, "cannot add dummy component: %d\n", r );
914
915     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
916     ok( r == S_OK, "cannot add test component: %d\n", r );
917
918     r = create_feature_table( hdb );
919     ok( r == S_OK, "cannot create Feature table: %d\n", r );
920
921     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
922     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
923
924     r = create_feature_components_table( hdb );
925     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
926
927     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
928     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
929
930     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
931     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
932
933     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
934     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
935
936     r = create_file_table( hdb );
937     ok( r == S_OK, "cannot create File table: %d\n", r );
938
939     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
940     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
941
942     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
943     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
944
945     hpkg = package_from_db( hdb );
946     ok( hpkg, "failed to create package\n");
947
948     r = MsiDoAction( hpkg, "CostInitialize");
949     ok( r == ERROR_SUCCESS, "cost init failed\n");
950
951     r = MsiDoAction( hpkg, "FileCost");
952     ok( r == ERROR_SUCCESS, "file cost failed\n");
953
954     r = MsiDoAction( hpkg, "CostFinalize");
955     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
956
957     r = MsiSetTargetPath( 0, NULL, NULL );
958     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
959
960     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
961     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
962
963     r = MsiSetTargetPath( hpkg, "boo", NULL );
964     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
965
966     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
967     ok( r == ERROR_DIRECTORY, "wrong return val\n");
968
969     sz = sizeof tempdir - 1;
970     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
971     sprintf( file, "%srootfile.txt", tempdir );
972     buffer[0] = 0;
973     query_file_path( hpkg, "[#RootFile]", buffer );
974     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
975     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
976
977     GetTempFileName( tempdir, "_wt", 0, buffer );
978     sprintf( tempdir, "%s\\subdir", buffer );
979
980     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
981     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
982         "MsiSetTargetPath on file returned %d\n", r );
983
984     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
985     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
986         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
987
988     DeleteFile( buffer );
989
990     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
991     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
992
993     r = GetFileAttributes( buffer );
994     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
995
996     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
997     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
998
999     sz = sizeof buffer - 1;
1000     lstrcat( tempdir, "\\" );
1001     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1002     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1003     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1004
1005     sprintf( file, "%srootfile.txt", tempdir );
1006     query_file_path( hpkg, "[#RootFile]", buffer );
1007     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1008
1009     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1010     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1011
1012     query_file_path( hpkg, "[#TestFile]", buffer );
1013     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1014         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1015
1016     sz = sizeof buffer - 1;
1017     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1018     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1019     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1020
1021     MsiCloseHandle( hpkg );
1022 }
1023
1024 static void test_condition(void)
1025 {
1026     MSICONDITION r;
1027     MSIHANDLE hpkg;
1028
1029     hpkg = package_from_db(create_package_db());
1030     ok( hpkg, "failed to create package\n");
1031
1032     r = MsiEvaluateCondition(0, NULL);
1033     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1034
1035     r = MsiEvaluateCondition(hpkg, NULL);
1036     ok( r == MSICONDITION_NONE, "wrong return val\n");
1037
1038     r = MsiEvaluateCondition(hpkg, "");
1039     ok( r == MSICONDITION_NONE, "wrong return val\n");
1040
1041     r = MsiEvaluateCondition(hpkg, "1");
1042     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1043
1044     r = MsiEvaluateCondition(hpkg, "0");
1045     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1046
1047     r = MsiEvaluateCondition(hpkg, "-1");
1048     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1049
1050     r = MsiEvaluateCondition(hpkg, "0 = 0");
1051     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1052
1053     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1054     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1055
1056     r = MsiEvaluateCondition(hpkg, "0 = 1");
1057     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1058
1059     r = MsiEvaluateCondition(hpkg, "0 > 1");
1060     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1061
1062     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1063     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1064
1065     r = MsiEvaluateCondition(hpkg, "1 > 1");
1066     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1067
1068     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1069     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1070
1071     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1072     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1073
1074     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1075     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1076
1077     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1078     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1079
1080     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1081     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1082
1083     r = MsiEvaluateCondition(hpkg, "0 < 1");
1084     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1085
1086     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1087     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1088
1089     r = MsiEvaluateCondition(hpkg, "1 < 1");
1090     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1091
1092     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1093     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1094
1095     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1096     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1097
1098     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1099     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1100
1101     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1102     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1103
1104     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1105     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1106
1107     r = MsiEvaluateCondition(hpkg, "0 >=");
1108     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1109
1110     r = MsiEvaluateCondition(hpkg, " ");
1111     ok( r == MSICONDITION_NONE, "wrong return val\n");
1112
1113     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1114     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1115
1116     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1117     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1118
1119     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1120     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1121
1122     r = MsiEvaluateCondition(hpkg, "not 0");
1123     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1124
1125     r = MsiEvaluateCondition(hpkg, "not LicView");
1126     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1127
1128     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1129     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1130
1131     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1132     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1133
1134     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1135     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1136
1137     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1138     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1139
1140     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1141     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1142
1143     r = MsiEvaluateCondition(hpkg, "\"0\"");
1144     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1145
1146     r = MsiEvaluateCondition(hpkg, "1 and 2");
1147     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1148
1149     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1150     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1151
1152     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1153     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1154
1155     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1156     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1157
1158     r = MsiEvaluateCondition(hpkg, "(0)");
1159     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1160
1161     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1162     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1163
1164     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1165     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1166
1167     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1168     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1169
1170     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1171     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1172
1173     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1174     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1175
1176     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1177     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1178
1179     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1180     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1181
1182     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1183     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1184
1185     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1186     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1187
1188     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1189     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1190
1191     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1192     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1193
1194     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1195     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1196
1197     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1198     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1199
1200     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1201     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1202
1203     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1204     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1205
1206     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1207     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1208
1209     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1210     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1211
1212     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1213     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1214
1215     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1216     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1217
1218     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1219     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1220
1221     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1222     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1223
1224     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1225     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1226
1227     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1228     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1229
1230     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1231     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1232
1233     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1234     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1235
1236     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1237     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1238
1239     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1240     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1241
1242     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1243     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1244
1245     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1246     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1247
1248     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1249     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1250
1251     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1252     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1253
1254     MsiSetProperty(hpkg, "mm", "5" );
1255
1256     r = MsiEvaluateCondition(hpkg, "mm = 5");
1257     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258
1259     r = MsiEvaluateCondition(hpkg, "mm < 6");
1260     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1263     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, "mm > 4");
1266     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, "mm < 12");
1269     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1272     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1275     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1278     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1281     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1284     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1287     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1290     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1293     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1296     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1299     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1302     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1305     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1308     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1311     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1314     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1317     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1318
1319     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1320     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1321
1322     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1323     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1324
1325     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1326     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1327
1328     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1329     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330
1331     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1332     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333
1334     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1335     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1336
1337     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1338     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1339
1340     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1341     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1342
1343     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1344     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345
1346     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1347     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1348
1349     MsiSetProperty(hpkg, "bandalmael", "0" );
1350     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1351     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1352
1353     MsiSetProperty(hpkg, "bandalmael", "" );
1354     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1355     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1356
1357     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1358     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1359     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1360
1361     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1362     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1363     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1364
1365     MsiSetProperty(hpkg, "bandalmael", "0 " );
1366     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1367     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1368
1369     MsiSetProperty(hpkg, "bandalmael", "-0" );
1370     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1371     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1372
1373     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1374     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1375     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1376
1377     MsiSetProperty(hpkg, "bandalmael", "--0" );
1378     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1379     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1380
1381     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1382     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1383     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1384
1385     MsiSetProperty(hpkg, "bandalmael", "-" );
1386     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1387     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1388
1389     MsiSetProperty(hpkg, "bandalmael", "+0" );
1390     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1391     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1392
1393     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1394     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1395     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1396     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1397     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1398
1399     MsiSetProperty(hpkg, "one", "hi");
1400     MsiSetProperty(hpkg, "two", "hithere");
1401     r = MsiEvaluateCondition(hpkg, "one >< two");
1402     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1403
1404     MsiSetProperty(hpkg, "one", "hithere");
1405     MsiSetProperty(hpkg, "two", "hi");
1406     r = MsiEvaluateCondition(hpkg, "one >< two");
1407     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1408
1409     MsiSetProperty(hpkg, "one", "hello");
1410     MsiSetProperty(hpkg, "two", "hi");
1411     r = MsiEvaluateCondition(hpkg, "one >< two");
1412     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1413
1414     MsiSetProperty(hpkg, "one", "hellohithere");
1415     MsiSetProperty(hpkg, "two", "hi");
1416     r = MsiEvaluateCondition(hpkg, "one >< two");
1417     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1418
1419     MsiSetProperty(hpkg, "one", "");
1420     MsiSetProperty(hpkg, "two", "hi");
1421     r = MsiEvaluateCondition(hpkg, "one >< two");
1422     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1423
1424     MsiSetProperty(hpkg, "one", "hi");
1425     MsiSetProperty(hpkg, "two", "");
1426     r = MsiEvaluateCondition(hpkg, "one >< two");
1427     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429     MsiSetProperty(hpkg, "one", "");
1430     MsiSetProperty(hpkg, "two", "");
1431     r = MsiEvaluateCondition(hpkg, "one >< two");
1432     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1433
1434     MsiSetProperty(hpkg, "one", "1234");
1435     MsiSetProperty(hpkg, "two", "1");
1436     r = MsiEvaluateCondition(hpkg, "one >< two");
1437     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1438
1439     MsiSetProperty(hpkg, "one", "one 1234");
1440     MsiSetProperty(hpkg, "two", "1");
1441     r = MsiEvaluateCondition(hpkg, "one >< two");
1442     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444     MsiSetProperty(hpkg, "one", "hithere");
1445     MsiSetProperty(hpkg, "two", "hi");
1446     r = MsiEvaluateCondition(hpkg, "one << two");
1447     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1448
1449     MsiSetProperty(hpkg, "one", "hi");
1450     MsiSetProperty(hpkg, "two", "hithere");
1451     r = MsiEvaluateCondition(hpkg, "one << two");
1452     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1453
1454     MsiSetProperty(hpkg, "one", "hi");
1455     MsiSetProperty(hpkg, "two", "hi");
1456     r = MsiEvaluateCondition(hpkg, "one << two");
1457     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1458
1459     MsiSetProperty(hpkg, "one", "abcdhithere");
1460     MsiSetProperty(hpkg, "two", "hi");
1461     r = MsiEvaluateCondition(hpkg, "one << two");
1462     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1463
1464     MsiSetProperty(hpkg, "one", "");
1465     MsiSetProperty(hpkg, "two", "hi");
1466     r = MsiEvaluateCondition(hpkg, "one << two");
1467     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1468
1469     MsiSetProperty(hpkg, "one", "hithere");
1470     MsiSetProperty(hpkg, "two", "");
1471     r = MsiEvaluateCondition(hpkg, "one << two");
1472     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1473
1474     MsiSetProperty(hpkg, "one", "");
1475     MsiSetProperty(hpkg, "two", "");
1476     r = MsiEvaluateCondition(hpkg, "one << two");
1477     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1478
1479     MsiSetProperty(hpkg, "one", "1234");
1480     MsiSetProperty(hpkg, "two", "1");
1481     r = MsiEvaluateCondition(hpkg, "one << two");
1482     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1483
1484     MsiSetProperty(hpkg, "one", "1234 one");
1485     MsiSetProperty(hpkg, "two", "1");
1486     r = MsiEvaluateCondition(hpkg, "one << two");
1487     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488
1489     MsiSetProperty(hpkg, "one", "hithere");
1490     MsiSetProperty(hpkg, "two", "there");
1491     r = MsiEvaluateCondition(hpkg, "one >> two");
1492     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1493
1494     MsiSetProperty(hpkg, "one", "hithere");
1495     MsiSetProperty(hpkg, "two", "hi");
1496     r = MsiEvaluateCondition(hpkg, "one >> two");
1497     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1498
1499     MsiSetProperty(hpkg, "one", "there");
1500     MsiSetProperty(hpkg, "two", "hithere");
1501     r = MsiEvaluateCondition(hpkg, "one >> two");
1502     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1503
1504     MsiSetProperty(hpkg, "one", "there");
1505     MsiSetProperty(hpkg, "two", "there");
1506     r = MsiEvaluateCondition(hpkg, "one >> two");
1507     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1508
1509     MsiSetProperty(hpkg, "one", "abcdhithere");
1510     MsiSetProperty(hpkg, "two", "hi");
1511     r = MsiEvaluateCondition(hpkg, "one >> two");
1512     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1513
1514     MsiSetProperty(hpkg, "one", "");
1515     MsiSetProperty(hpkg, "two", "there");
1516     r = MsiEvaluateCondition(hpkg, "one >> two");
1517     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1518
1519     MsiSetProperty(hpkg, "one", "there");
1520     MsiSetProperty(hpkg, "two", "");
1521     r = MsiEvaluateCondition(hpkg, "one >> two");
1522     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1523
1524     MsiSetProperty(hpkg, "one", "");
1525     MsiSetProperty(hpkg, "two", "");
1526     r = MsiEvaluateCondition(hpkg, "one >> two");
1527     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1528
1529     MsiSetProperty(hpkg, "one", "1234");
1530     MsiSetProperty(hpkg, "two", "4");
1531     r = MsiEvaluateCondition(hpkg, "one >> two");
1532     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1533
1534     MsiSetProperty(hpkg, "one", "one 1234");
1535     MsiSetProperty(hpkg, "two", "4");
1536     r = MsiEvaluateCondition(hpkg, "one >> two");
1537     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1538
1539     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1540
1541     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1542     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1543
1544     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1545     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1546
1547     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1548     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1549
1550     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1551     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1552
1553     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1554     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1555
1556     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1557     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1558
1559     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1560     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1561
1562     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1563     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1564
1565     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1566     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1567
1568     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1569     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1570
1571     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1572     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1573
1574     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1575     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1576
1577     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1578     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1579
1580     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1581     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1582
1583     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1584     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1585
1586     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1587     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1588
1589     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1590     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1591
1592     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1593     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1594
1595     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1596     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1597
1598     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1599     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1600
1601     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1602     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1603
1604     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1605     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1606
1607     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1608     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1609
1610     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1611     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1612
1613     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1614     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1615
1616     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1617     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1618
1619     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1620     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1621
1622     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1623     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1624
1625     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1626     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1627
1628     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1629     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1630
1631     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1632     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1633
1634     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1635     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1636
1637     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1638     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1639
1640     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1641     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1642
1643     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1644     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1645
1646     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1647     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1648
1649     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1650     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1651
1652     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1653     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1654     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1655
1656     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1657     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1658
1659     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1660     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1661
1662     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1663     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1664
1665     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1666     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1667
1668     MsiSetProperty(hpkg, "one", "1");
1669     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1670     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1671
1672     MsiSetProperty(hpkg, "X", "5.0");
1673
1674     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1675     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1676
1677     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1678     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1679
1680     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1681     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1682
1683     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1684     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1685
1686     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1687     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1688
1689     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1690     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1691
1692     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1693     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1694
1695     /* feature doesn't exist */
1696     r = MsiEvaluateCondition(hpkg, "&nofeature");
1697     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1698
1699     MsiSetProperty(hpkg, "A", "2");
1700     MsiSetProperty(hpkg, "X", "50");
1701
1702     r = MsiEvaluateCondition(hpkg, "2 <= X");
1703     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1704
1705     r = MsiEvaluateCondition(hpkg, "A <= X");
1706     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1707
1708     r = MsiEvaluateCondition(hpkg, "A <= 50");
1709     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1710
1711     MsiSetProperty(hpkg, "X", "50val");
1712
1713     r = MsiEvaluateCondition(hpkg, "2 <= X");
1714     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1715
1716     r = MsiEvaluateCondition(hpkg, "A <= X");
1717     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1718
1719     MsiSetProperty(hpkg, "A", "7");
1720     MsiSetProperty(hpkg, "X", "50");
1721
1722     r = MsiEvaluateCondition(hpkg, "7 <= X");
1723     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1724
1725     r = MsiEvaluateCondition(hpkg, "A <= X");
1726     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1727
1728     r = MsiEvaluateCondition(hpkg, "A <= 50");
1729     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1730
1731     MsiSetProperty(hpkg, "X", "50val");
1732
1733     r = MsiEvaluateCondition(hpkg, "2 <= X");
1734     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1735
1736     r = MsiEvaluateCondition(hpkg, "A <= X");
1737     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1738
1739     MsiCloseHandle( hpkg );
1740     DeleteFile(msifile);
1741 }
1742
1743 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1744 {
1745     UINT r;
1746     DWORD sz;
1747     char buffer[2];
1748
1749     sz = sizeof buffer;
1750     strcpy(buffer,"x");
1751     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1752     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1753 }
1754
1755 static void test_props(void)
1756 {
1757     MSIHANDLE hpkg, hdb;
1758     UINT r;
1759     DWORD sz;
1760     char buffer[0x100];
1761
1762     hdb = create_package_db();
1763     r = run_query( hdb,
1764             "CREATE TABLE `Property` ( "
1765             "`Property` CHAR(255) NOT NULL, "
1766             "`Value` CHAR(255) "
1767             "PRIMARY KEY `Property`)" );
1768     ok( r == ERROR_SUCCESS , "Failed\n" );
1769
1770     r = run_query(hdb,
1771             "INSERT INTO `Property` "
1772             "(`Property`, `Value`) "
1773             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1774     ok( r == ERROR_SUCCESS , "Failed\n" );
1775
1776     hpkg = package_from_db( hdb );
1777     ok( hpkg, "failed to create package\n");
1778
1779     /* test invalid values */
1780     r = MsiGetProperty( 0, NULL, NULL, NULL );
1781     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1782
1783     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1784     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1785
1786     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1787     ok( r == ERROR_SUCCESS, "wrong return val\n");
1788
1789     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1790     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1791
1792     /* test retrieving an empty/nonexistent property */
1793     sz = sizeof buffer;
1794     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1795     ok( r == ERROR_SUCCESS, "wrong return val\n");
1796     ok( sz == 0, "wrong size returned\n");
1797
1798     check_prop_empty( hpkg, "boo");
1799     sz = 0;
1800     strcpy(buffer,"x");
1801     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1802     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1803     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1804     ok( sz == 0, "wrong size returned\n");
1805
1806     sz = 1;
1807     strcpy(buffer,"x");
1808     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1809     ok( r == ERROR_SUCCESS, "wrong return val\n");
1810     ok( buffer[0] == 0, "buffer was not changed\n");
1811     ok( sz == 0, "wrong size returned\n");
1812
1813     /* set the property to something */
1814     r = MsiSetProperty( 0, NULL, NULL );
1815     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1816
1817     r = MsiSetProperty( hpkg, NULL, NULL );
1818     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1819
1820     r = MsiSetProperty( hpkg, "", NULL );
1821     ok( r == ERROR_SUCCESS, "wrong return val\n");
1822
1823     /* try set and get some illegal property identifiers */
1824     r = MsiSetProperty( hpkg, "", "asdf" );
1825     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1826
1827     r = MsiSetProperty( hpkg, "=", "asdf" );
1828     ok( r == ERROR_SUCCESS, "wrong return val\n");
1829
1830     r = MsiSetProperty( hpkg, " ", "asdf" );
1831     ok( r == ERROR_SUCCESS, "wrong return val\n");
1832
1833     r = MsiSetProperty( hpkg, "'", "asdf" );
1834     ok( r == ERROR_SUCCESS, "wrong return val\n");
1835
1836     sz = sizeof buffer;
1837     buffer[0]=0;
1838     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1839     ok( r == ERROR_SUCCESS, "wrong return val\n");
1840     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1841
1842     /* set empty values */
1843     r = MsiSetProperty( hpkg, "boo", NULL );
1844     ok( r == ERROR_SUCCESS, "wrong return val\n");
1845     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1846
1847     r = MsiSetProperty( hpkg, "boo", "" );
1848     ok( r == ERROR_SUCCESS, "wrong return val\n");
1849     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1850
1851     /* set a non-empty value */
1852     r = MsiSetProperty( hpkg, "boo", "xyz" );
1853     ok( r == ERROR_SUCCESS, "wrong return val\n");
1854
1855     sz = 1;
1856     strcpy(buffer,"x");
1857     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1858     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1859     ok( buffer[0] == 0, "buffer was not changed\n");
1860     ok( sz == 3, "wrong size returned\n");
1861
1862     sz = 4;
1863     strcpy(buffer,"x");
1864     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1865     ok( r == ERROR_SUCCESS, "wrong return val\n");
1866     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1867     ok( sz == 3, "wrong size returned\n");
1868
1869     sz = 3;
1870     strcpy(buffer,"x");
1871     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1872     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1873     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1874     ok( sz == 3, "wrong size returned\n");
1875
1876     r = MsiSetProperty(hpkg, "SourceDir", "foo");
1877     ok( r == ERROR_SUCCESS, "wrong return val\n");
1878
1879     sz = 4;
1880     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1881     ok( r == ERROR_SUCCESS, "wrong return val\n");
1882     ok( !strcmp(buffer,""), "buffer wrong\n");
1883     ok( sz == 0, "wrong size returned\n");
1884
1885     sz = 4;
1886     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1887     ok( r == ERROR_SUCCESS, "wrong return val\n");
1888     ok( !strcmp(buffer,""), "buffer wrong\n");
1889     ok( sz == 0, "wrong size returned\n");
1890
1891     sz = 4;
1892     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1893     ok( r == ERROR_SUCCESS, "wrong return val\n");
1894     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1895     ok( sz == 3, "wrong size returned\n");
1896
1897     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1898     ok( r == ERROR_SUCCESS, "wrong return val\n");
1899
1900     sz = 0;
1901     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1902     ok( r == ERROR_SUCCESS, "return wrong\n");
1903     ok( sz == 13, "size wrong (%d)\n", sz);
1904
1905     sz = 13;
1906     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1907     ok( r == ERROR_MORE_DATA, "return wrong\n");
1908     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1909
1910     r = MsiSetProperty(hpkg, "property", "value");
1911     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1912
1913     sz = 6;
1914     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1915     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1916     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1917
1918     r = MsiSetProperty(hpkg, "property", NULL);
1919     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1920
1921     sz = 6;
1922     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1923     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1924     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1925
1926     MsiCloseHandle( hpkg );
1927     DeleteFile(msifile);
1928 }
1929
1930 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
1931 {
1932     MSIHANDLE hview, hrec;
1933     BOOL found;
1934     CHAR buffer[MAX_PATH];
1935     DWORD sz;
1936     UINT r;
1937
1938     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
1939     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1940     r = MsiViewExecute(hview, 0);
1941     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
1942
1943     found = FALSE;
1944     while (r == ERROR_SUCCESS && !found)
1945     {
1946         r = MsiViewFetch(hview, &hrec);
1947         if (r != ERROR_SUCCESS) break;
1948
1949         sz = MAX_PATH;
1950         r = MsiRecordGetString(hrec, 1, buffer, &sz);
1951         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
1952         {
1953             sz = MAX_PATH;
1954             r = MsiRecordGetString(hrec, 2, buffer, &sz);
1955             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
1956                 found = TRUE;
1957         }
1958
1959         MsiCloseHandle(hrec);
1960     }
1961
1962     MsiViewClose(hview);
1963     MsiCloseHandle(hview);
1964
1965     return found;
1966 }
1967
1968 static void test_property_table(void)
1969 {
1970     const char *query;
1971     UINT r;
1972     MSIHANDLE hpkg, hdb, hrec;
1973     char buffer[MAX_PATH];
1974     DWORD sz;
1975     BOOL found;
1976
1977     hdb = create_package_db();
1978     ok( hdb, "failed to create package\n");
1979
1980     hpkg = package_from_db(hdb);
1981     ok( hpkg, "failed to create package\n");
1982
1983     MsiCloseHandle(hdb);
1984
1985     hdb = MsiGetActiveDatabase(hpkg);
1986
1987     query = "CREATE TABLE `_Property` ( "
1988         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1989     r = run_query(hdb, query);
1990     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1991
1992     MsiCloseHandle(hdb);
1993     MsiCloseHandle(hpkg);
1994     DeleteFile(msifile);
1995
1996     hdb = create_package_db();
1997     ok( hdb, "failed to create package\n");
1998
1999     query = "CREATE TABLE `_Property` ( "
2000         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2001     r = run_query(hdb, query);
2002     ok(r == ERROR_SUCCESS, "failed to create table\n");
2003
2004     query = "ALTER `_Property` ADD `foo` INTEGER";
2005     r = run_query(hdb, query);
2006     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2007
2008     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2009     r = run_query(hdb, query);
2010     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2011
2012     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2013     r = run_query(hdb, query);
2014     ok(r == ERROR_SUCCESS, "failed to add column\n");
2015
2016     hpkg = package_from_db(hdb);
2017     todo_wine
2018     {
2019         ok(!hpkg, "package should not be created\n");
2020     }
2021
2022     MsiCloseHandle(hdb);
2023     MsiCloseHandle(hpkg);
2024     DeleteFile(msifile);
2025
2026     hdb = create_package_db();
2027     ok (hdb, "failed to create package database\n");
2028
2029     r = create_property_table(hdb);
2030     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2031
2032     r = add_property_entry(hdb, "'prop', 'val'");
2033     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2034
2035     hpkg = package_from_db(hdb);
2036     ok(hpkg, "failed to create package\n");
2037
2038     MsiCloseHandle(hdb);
2039
2040     sz = MAX_PATH;
2041     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2042     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2043     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2044
2045     hdb = MsiGetActiveDatabase(hpkg);
2046
2047     found = find_prop_in_property(hdb, "prop", "val");
2048     ok(found, "prop should be in the _Property table\n");
2049
2050     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2051     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2052
2053     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2054     r = do_query(hdb, query, &hrec);
2055     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2056
2057     found = find_prop_in_property(hdb, "dantes", "mercedes");
2058     ok(found == FALSE, "dantes should not be in the _Property table\n");
2059
2060     sz = MAX_PATH;
2061     lstrcpy(buffer, "aaa");
2062     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2063     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2064     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2065
2066     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2067     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2068
2069     found = find_prop_in_property(hdb, "dantes", "mercedes");
2070     ok(found == TRUE, "dantes should be in the _Property table\n");
2071
2072     MsiCloseHandle(hdb);
2073     MsiCloseHandle(hpkg);
2074     DeleteFile(msifile);
2075 }
2076
2077 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2078 {
2079     MSIHANDLE htab = 0;
2080     UINT res;
2081
2082     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2083     if( res == ERROR_SUCCESS )
2084     {
2085         UINT r;
2086
2087         r = MsiViewExecute( htab, hrec );
2088         if( r != ERROR_SUCCESS )
2089         {
2090             res = r;
2091             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2092         }
2093
2094         r = MsiViewClose( htab );
2095         if( r != ERROR_SUCCESS )
2096             res = r;
2097
2098         r = MsiCloseHandle( htab );
2099         if( r != ERROR_SUCCESS )
2100             res = r;
2101     }
2102     return res;
2103 }
2104
2105 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2106 {
2107     return try_query_param( hdb, szQuery, 0 );
2108 }
2109
2110 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2111 {
2112     MSIHANDLE summary;
2113     UINT r;
2114
2115     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2116     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2117
2118     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2120
2121     r = MsiSummaryInfoPersist(summary);
2122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2123
2124     MsiCloseHandle(summary);
2125 }
2126
2127 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2128 {
2129     MSIHANDLE summary;
2130     UINT r;
2131
2132     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2134
2135     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2136     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2137
2138     r = MsiSummaryInfoPersist(summary);
2139     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2140
2141     MsiCloseHandle(summary);
2142 }
2143
2144 static void test_msipackage(void)
2145 {
2146     MSIHANDLE hdb = 0, hpack = 100;
2147     UINT r;
2148     const char *query;
2149     char name[10];
2150
2151     /* NULL szPackagePath */
2152     r = MsiOpenPackage(NULL, &hpack);
2153     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2154
2155     /* empty szPackagePath */
2156     r = MsiOpenPackage("", &hpack);
2157     todo_wine
2158     {
2159         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2160     }
2161
2162     if (r == ERROR_SUCCESS)
2163         MsiCloseHandle(hpack);
2164
2165     /* nonexistent szPackagePath */
2166     r = MsiOpenPackage("nonexistent", &hpack);
2167     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2168
2169     /* NULL hProduct */
2170     r = MsiOpenPackage(msifile, NULL);
2171     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2172
2173     name[0]='#';
2174     name[1]=0;
2175     r = MsiOpenPackage(name, &hpack);
2176     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2177
2178     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2179     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2180
2181     /* database exists, but is emtpy */
2182     sprintf(name, "#%d", hdb);
2183     r = MsiOpenPackage(name, &hpack);
2184     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2185        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2186
2187     query = "CREATE TABLE `Property` ( "
2188             "`Property` CHAR(72), `Value` CHAR(0) "
2189             "PRIMARY KEY `Property`)";
2190     r = try_query(hdb, query);
2191     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2192
2193     query = "CREATE TABLE `InstallExecuteSequence` ("
2194             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2195             "PRIMARY KEY `Action`)";
2196     r = try_query(hdb, query);
2197     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2198
2199     /* a few key tables exist */
2200     sprintf(name, "#%d", hdb);
2201     r = MsiOpenPackage(name, &hpack);
2202     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2203        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2204
2205     MsiCloseHandle(hdb);
2206     DeleteFile(msifile);
2207
2208     /* start with a clean database to show what constitutes a valid package */
2209     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2210     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2211
2212     sprintf(name, "#%d", hdb);
2213
2214     /* The following summary information props must exist:
2215      *  - PID_REVNUMBER
2216      *  - PID_PAGECOUNT
2217      */
2218
2219     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2220     r = MsiOpenPackage(name, &hpack);
2221     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2222        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2223
2224     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2225     r = MsiOpenPackage(name, &hpack);
2226     ok(r == ERROR_SUCCESS,
2227        "Expected ERROR_SUCCESS, got %d\n", r);
2228
2229     MsiCloseHandle(hpack);
2230     MsiCloseHandle(hdb);
2231     DeleteFile(msifile);
2232 }
2233
2234 static void test_formatrecord2(void)
2235 {
2236     MSIHANDLE hpkg, hrec ;
2237     char buffer[0x100];
2238     DWORD sz;
2239     UINT r;
2240
2241     hpkg = package_from_db(create_package_db());
2242     ok( hpkg, "failed to create package\n");
2243
2244     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2245     ok( r == ERROR_SUCCESS, "set property failed\n");
2246
2247     hrec = MsiCreateRecord(2);
2248     ok(hrec, "create record failed\n");
2249
2250     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2251     ok( r == ERROR_SUCCESS, "format record failed\n");
2252
2253     buffer[0] = 0;
2254     sz = sizeof buffer;
2255     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2256
2257     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2258     r = MsiRecordSetString(hrec, 1, "hoo");
2259     sz = sizeof buffer;
2260     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2261     ok( sz == 3, "size wrong\n");
2262     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2263     ok( r == ERROR_SUCCESS, "format failed\n");
2264
2265     r = MsiRecordSetString(hrec, 0, "x[~]x");
2266     sz = sizeof buffer;
2267     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2268     ok( sz == 3, "size wrong\n");
2269     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2270     ok( r == ERROR_SUCCESS, "format failed\n");
2271
2272     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2273     r = MsiRecordSetString(hrec, 1, "hoo");
2274     sz = sizeof buffer;
2275     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2276     ok( sz == 3, "size wrong\n");
2277     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2278     ok( r == ERROR_SUCCESS, "format failed\n");
2279
2280     r = MsiRecordSetString(hrec, 0, "[\\[]");
2281     sz = sizeof buffer;
2282     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2283     ok( sz == 1, "size wrong\n");
2284     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2285     ok( r == ERROR_SUCCESS, "format failed\n");
2286
2287     SetEnvironmentVariable("FOO", "BAR");
2288     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2289     sz = sizeof buffer;
2290     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2291     ok( sz == 3, "size wrong\n");
2292     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2293     ok( r == ERROR_SUCCESS, "format failed\n");
2294
2295     r = MsiRecordSetString(hrec, 0, "[[1]]");
2296     r = MsiRecordSetString(hrec, 1, "%FOO");
2297     sz = sizeof buffer;
2298     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2299     ok( sz == 3, "size wrong\n");
2300     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2301     ok( r == ERROR_SUCCESS, "format failed\n");
2302
2303     MsiCloseHandle( hrec );
2304     MsiCloseHandle( hpkg );
2305     DeleteFile(msifile);
2306 }
2307
2308 static void test_states(void)
2309 {
2310     MSIHANDLE hpkg;
2311     UINT r;
2312     MSIHANDLE hdb;
2313     INSTALLSTATE state, action;
2314
2315     static const CHAR msifile2[] = "winetest2.msi";
2316     static const CHAR msifile3[] = "winetest3.msi";
2317     static const CHAR msifile4[] = "winetest4.msi";
2318
2319     hdb = create_package_db();
2320     ok ( hdb, "failed to create package database\n" );
2321
2322     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2323     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2324
2325     r = create_property_table( hdb );
2326     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2327
2328     r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2329     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2330
2331     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2332     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2333
2334     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2335     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2336
2337     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2338     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2339
2340     r = create_install_execute_sequence_table( hdb );
2341     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2342
2343     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2344     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2345
2346     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2347     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2348
2349     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2350     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2351
2352     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2353     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2354
2355     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2356     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2357
2358     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2359     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2360
2361     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2362     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2363
2364     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2365     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2366
2367     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2368     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2369
2370     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2371     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2372
2373     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2374     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2375
2376     r = create_media_table( hdb );
2377     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2378
2379     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2380     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2381
2382     r = create_feature_table( hdb );
2383     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2384
2385     r = create_component_table( hdb );
2386     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2387
2388     /* msidbFeatureAttributesFavorLocal */
2389     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2390     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2391
2392     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2393     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2394     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2395
2396     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2397     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2398     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2399
2400     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2401     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2402     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2403
2404     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2405     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2406     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2407
2408     /* msidbFeatureAttributesFavorSource */
2409     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2410     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2411
2412     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2413     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2414     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2415
2416     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2417     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2418     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2419
2420     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2421     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2422     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2423
2424     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2425     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2426     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2427
2428     /* msidbFeatureAttributesFavorSource */
2429     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2430     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2431
2432     /* msidbFeatureAttributesFavorLocal */
2433     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2434     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2435
2436     /* disabled */
2437     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2438     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2439
2440     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2441     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2442     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2443
2444     /* no feature parent:msidbComponentAttributesLocalOnly */
2445     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2446     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2447
2448     /* msidbFeatureAttributesFavorLocal:removed */
2449     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2450     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2451
2452     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2453     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2454     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2455
2456     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2457     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2458     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2459
2460     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2461     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2462     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2463
2464     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2465     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2466     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2467
2468     /* msidbFeatureAttributesFavorSource:removed */
2469     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2470     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2471
2472     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2473     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2474     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2475
2476     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2477     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2478     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2479
2480     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2481     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2482     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2483
2484     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2485     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2486     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2487
2488     /* msidbFeatureAttributesFavorLocal */
2489     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2490     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2491
2492     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2493     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2494
2495     /* msidbFeatureAttributesFavorSource */
2496     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2497     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2498
2499     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2500     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2501
2502     /* msidbFeatureAttributesFavorAdvertise */
2503     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2504     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2505
2506     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2507     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2508
2509     r = create_feature_components_table( hdb );
2510     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2511
2512     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2513     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2514
2515     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2516     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2517
2518     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2519     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2520
2521     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2522     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2523
2524     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2525     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2526
2527     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2528     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2529
2530     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2531     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2532
2533     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2534     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2535
2536     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2537     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2538
2539     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2540     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2541
2542     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2543     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2544
2545     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2546     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2547
2548     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2549     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2550
2551     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2552     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2553
2554     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2555     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2556
2557     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2558     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2559
2560     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2561     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2562
2563     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2564     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2565
2566     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2567     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2568
2569     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2570     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2571
2572     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2573     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2574
2575     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2576     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2577
2578     r = create_file_table( hdb );
2579     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2580
2581     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2582     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2583
2584     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2585     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2586
2587     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2588     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2589
2590     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2591     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2592
2593     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2594     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2595
2596     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2597     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2598
2599     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2600     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2601
2602     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2603     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2604
2605     /* compressed file */
2606     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2607     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2608
2609     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2610     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2611
2612     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2613     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2614
2615     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2616     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2617
2618     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2619     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2620
2621     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2622     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2623
2624     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2625     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2626
2627     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2628     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2629
2630     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2631     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2632
2633     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2634     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2635
2636     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2637     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2638
2639     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2640     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2641
2642     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2643     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2644
2645     MsiDatabaseCommit(hdb);
2646
2647     /* these properties must not be in the saved msi file */
2648     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2649     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2650
2651     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2652     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2653
2654     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2655     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2656
2657     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2658     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2659
2660     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2661     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2662
2663     hpkg = package_from_db( hdb );
2664     ok( hpkg, "failed to create package\n");
2665
2666     MsiCloseHandle(hdb);
2667
2668     CopyFileA(msifile, msifile2, FALSE);
2669     CopyFileA(msifile, msifile3, FALSE);
2670     CopyFileA(msifile, msifile4, FALSE);
2671
2672     state = 0xdeadbee;
2673     action = 0xdeadbee;
2674     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2675     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2676     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2677     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2678
2679     state = 0xdeadbee;
2680     action = 0xdeadbee;
2681     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2682     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2683     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2684     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2685
2686     state = 0xdeadbee;
2687     action = 0xdeadbee;
2688     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2689     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2690     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2691     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2692
2693     state = 0xdeadbee;
2694     action = 0xdeadbee;
2695     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2696     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2697     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2698     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2699
2700     state = 0xdeadbee;
2701     action = 0xdeadbee;
2702     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2703     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2704     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2705     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2706
2707     state = 0xdeadbee;
2708     action = 0xdeadbee;
2709     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2710     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2711     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2712     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2713
2714     state = 0xdeadbee;
2715     action = 0xdeadbee;
2716     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2717     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2718     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2719     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2720
2721     state = 0xdeadbee;
2722     action = 0xdeadbee;
2723     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2724     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2725     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2726     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2727
2728     state = 0xdeadbee;
2729     action = 0xdeadbee;
2730     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2731     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2732     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2733     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2734
2735     state = 0xdeadbee;
2736     action = 0xdeadbee;
2737     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2738     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2739     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2740     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2741
2742     state = 0xdeadbee;
2743     action = 0xdeadbee;
2744     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2745     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2746     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2747     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2748
2749     state = 0xdeadbee;
2750     action = 0xdeadbee;
2751     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2752     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2753     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2754     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2755
2756     state = 0xdeadbee;
2757     action = 0xdeadbee;
2758     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2759     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2760     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2761     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2762
2763     state = 0xdeadbee;
2764     action = 0xdeadbee;
2765     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2766     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2767     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2768     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2769
2770     state = 0xdeadbee;
2771     action = 0xdeadbee;
2772     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2773     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2774     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2775     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2776
2777     state = 0xdeadbee;
2778     action = 0xdeadbee;
2779     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2780     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2781     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2782     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2783
2784     state = 0xdeadbee;
2785     action = 0xdeadbee;
2786     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2787     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2788     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2789     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2790
2791     state = 0xdeadbee;
2792     action = 0xdeadbee;
2793     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2794     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2795     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2796     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2797
2798     state = 0xdeadbee;
2799     action = 0xdeadbee;
2800     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2801     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2802     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2803     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2804
2805     state = 0xdeadbee;
2806     action = 0xdeadbee;
2807     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2808     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2809     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2810     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2811
2812     state = 0xdeadbee;
2813     action = 0xdeadbee;
2814     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2815     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2816     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2817     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2818
2819     state = 0xdeadbee;
2820     action = 0xdeadbee;
2821     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2822     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2823     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2824     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2825
2826     state = 0xdeadbee;
2827     action = 0xdeadbee;
2828     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2829     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2830     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2831     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2832
2833     state = 0xdeadbee;
2834     action = 0xdeadbee;
2835     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2836     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2837     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2838     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2839
2840     state = 0xdeadbee;
2841     action = 0xdeadbee;
2842     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2843     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2844     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2845     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2846
2847     state = 0xdeadbee;
2848     action = 0xdeadbee;
2849     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2850     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2851     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2852     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2853
2854     state = 0xdeadbee;
2855     action = 0xdeadbee;
2856     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2857     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2858     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2859     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2860
2861     state = 0xdeadbee;
2862     action = 0xdeadbee;
2863     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2864     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2865     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2866     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2867
2868     state = 0xdeadbee;
2869     action = 0xdeadbee;
2870     r = MsiGetComponentState(hpkg, "tau", &state, &action);
2871     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2872     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2873     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2874
2875     state = 0xdeadbee;
2876     action = 0xdeadbee;
2877     r = MsiGetComponentState(hpkg, "phi", &state, &action);
2878     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2879     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2880     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2881
2882     state = 0xdeadbee;
2883     action = 0xdeadbee;
2884     r = MsiGetComponentState(hpkg, "chi", &state, &action);
2885     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2886     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2887     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2888
2889     r = MsiDoAction( hpkg, "CostInitialize");
2890     ok( r == ERROR_SUCCESS, "cost init failed\n");
2891
2892     state = 0xdeadbee;
2893     action = 0xdeadbee;
2894     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2895     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2896     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2897     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2898
2899     state = 0xdeadbee;
2900     action = 0xdeadbee;
2901     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2902     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2903     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2904     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2905
2906     state = 0xdeadbee;
2907     action = 0xdeadbee;
2908     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2909     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2910     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2911     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2912
2913     state = 0xdeadbee;
2914     action = 0xdeadbee;
2915     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2916     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2917     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2918     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2919
2920     state = 0xdeadbee;
2921     action = 0xdeadbee;
2922     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2923     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2924     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2925     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2926
2927     state = 0xdeadbee;
2928     action = 0xdeadbee;
2929     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2930     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2931     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2932     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2933
2934     state = 0xdeadbee;
2935     action = 0xdeadbee;
2936     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2937     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2938     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2939     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2940
2941     state = 0xdeadbee;
2942     action = 0xdeadbee;
2943     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2944     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2945     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2946     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2947
2948     state = 0xdeadbee;
2949     action = 0xdeadbee;
2950     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2951     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2952     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2953     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2954
2955     state = 0xdeadbee;
2956     action = 0xdeadbee;
2957     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2958     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2959     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2960     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2961
2962     state = 0xdeadbee;
2963     action = 0xdeadbee;
2964     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2965     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2966     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2967     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2968
2969     state = 0xdeadbee;
2970     action = 0xdeadbee;
2971     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2972     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2973     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2974     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2975
2976     state = 0xdeadbee;
2977     action = 0xdeadbee;
2978     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2979     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2980     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2981     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2982
2983     state = 0xdeadbee;
2984     action = 0xdeadbee;
2985     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2986     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2987     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2988     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2989
2990     state = 0xdeadbee;
2991     action = 0xdeadbee;
2992     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2993     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2994     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2995     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2996
2997     state = 0xdeadbee;
2998     action = 0xdeadbee;
2999     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3000     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3001     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3002     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3003
3004     state = 0xdeadbee;
3005     action = 0xdeadbee;
3006     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3007     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3008     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3009     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3010
3011     state = 0xdeadbee;
3012     action = 0xdeadbee;
3013     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3014     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3015     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3016     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3017
3018     state = 0xdeadbee;
3019     action = 0xdeadbee;
3020     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3021     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3022     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3023     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3024
3025     state = 0xdeadbee;
3026     action = 0xdeadbee;
3027     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3028     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3029     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3030     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3031
3032     state = 0xdeadbee;
3033     action = 0xdeadbee;
3034     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3035     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3036     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3037     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3038
3039     state = 0xdeadbee;
3040     action = 0xdeadbee;
3041     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3042     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3043     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3044     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3045
3046     state = 0xdeadbee;
3047     action = 0xdeadbee;
3048     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3049     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3050     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3051     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3052
3053     state = 0xdeadbee;
3054     action = 0xdeadbee;
3055     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3056     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3057     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3058     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3059
3060     state = 0xdeadbee;
3061     action = 0xdeadbee;
3062     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3063     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3064     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3065     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3066
3067     state = 0xdeadbee;
3068     action = 0xdeadbee;
3069     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3070     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3071     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3072     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3073
3074     state = 0xdeadbee;
3075     action = 0xdeadbee;
3076     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3080
3081     state = 0xdeadbee;
3082     action = 0xdeadbee;
3083     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3087
3088     state = 0xdeadbee;
3089     action = 0xdeadbee;
3090     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3094
3095     state = 0xdeadbee;
3096     action = 0xdeadbee;
3097     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3101
3102     state = 0xdeadbee;
3103     action = 0xdeadbee;
3104     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3108
3109     r = MsiDoAction( hpkg, "FileCost");
3110     ok( r == ERROR_SUCCESS, "file cost failed\n");
3111
3112     state = 0xdeadbee;
3113     action = 0xdeadbee;
3114     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3115     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3116     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3117     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3118
3119     state = 0xdeadbee;
3120     action = 0xdeadbee;
3121     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3122     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3123     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3124     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3125
3126     state = 0xdeadbee;
3127     action = 0xdeadbee;
3128     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3129     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3130     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3131     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3132
3133     state = 0xdeadbee;
3134     action = 0xdeadbee;
3135     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3136     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3137     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3138     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3139
3140     state = 0xdeadbee;
3141     action = 0xdeadbee;
3142     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3143     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3144     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3145     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3146
3147     state = 0xdeadbee;
3148     action = 0xdeadbee;
3149     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3150     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3151     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3152     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3153
3154     state = 0xdeadbee;
3155     action = 0xdeadbee;
3156     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3157     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3158     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3159     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3160
3161     state = 0xdeadbee;
3162     action = 0xdeadbee;
3163     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3164     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3165     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3166     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3167
3168     state = 0xdeadbee;
3169     action = 0xdeadbee;
3170     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3171     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3172     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3173     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3174
3175     state = 0xdeadbee;
3176     action = 0xdeadbee;
3177     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3178     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3179     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3180     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3181
3182     state = 0xdeadbee;
3183     action = 0xdeadbee;
3184     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3185     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3186     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3187     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3188
3189     state = 0xdeadbee;
3190     action = 0xdeadbee;
3191     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3192     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3193     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3194     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3195
3196     state = 0xdeadbee;
3197     action = 0xdeadbee;
3198     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3199     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3200     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3201     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3202
3203     state = 0xdeadbee;
3204     action = 0xdeadbee;
3205     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3206     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3207     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3208     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3209
3210     state = 0xdeadbee;
3211     action = 0xdeadbee;
3212     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3213     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3214     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3215     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3216
3217     state = 0xdeadbee;
3218     action = 0xdeadbee;
3219     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3220     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3221     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3222     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3223
3224     state = 0xdeadbee;
3225     action = 0xdeadbee;
3226     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3227     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3228     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3229     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3230
3231     state = 0xdeadbee;
3232     action = 0xdeadbee;
3233     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3234     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3235     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3236     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3237
3238     state = 0xdeadbee;
3239     action = 0xdeadbee;
3240     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3241     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3242     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3243     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3244
3245     state = 0xdeadbee;
3246     action = 0xdeadbee;
3247     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3248     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3249     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3250     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3251
3252     state = 0xdeadbee;
3253     action = 0xdeadbee;
3254     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3255     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3256     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3257     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3258
3259     state = 0xdeadbee;
3260     action = 0xdeadbee;
3261     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3262     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3263     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3264     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3265
3266     state = 0xdeadbee;
3267     action = 0xdeadbee;
3268     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3269     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3270     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3271     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3272
3273     state = 0xdeadbee;
3274     action = 0xdeadbee;
3275     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3276     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3277     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3278     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3279
3280     state = 0xdeadbee;
3281     action = 0xdeadbee;
3282     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3283     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3284     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3285     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3286
3287     state = 0xdeadbee;
3288     action = 0xdeadbee;
3289     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3290     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3291     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3292     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3293
3294     state = 0xdeadbee;
3295     action = 0xdeadbee;
3296     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3297     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3298     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3299     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3300
3301     state = 0xdeadbee;
3302     action = 0xdeadbee;
3303     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3304     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3305     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3306     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3307
3308     state = 0xdeadbee;
3309     action = 0xdeadbee;
3310     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3312     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3313     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3314
3315     state = 0xdeadbee;
3316     action = 0xdeadbee;
3317     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3319     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3320     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3321
3322     state = 0xdeadbee;
3323     action = 0xdeadbee;
3324     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3326     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3327     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3328
3329     r = MsiDoAction( hpkg, "CostFinalize");
3330     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3331
3332     state = 0xdeadbee;
3333     action = 0xdeadbee;
3334     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3335     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3336     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3337     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3338
3339     state = 0xdeadbee;
3340     action = 0xdeadbee;
3341     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3342     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3343     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3344     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3345
3346     state = 0xdeadbee;
3347     action = 0xdeadbee;
3348     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3349     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3350     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3351     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3352
3353     state = 0xdeadbee;
3354     action = 0xdeadbee;
3355     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3356     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3357     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3358     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3359
3360     state = 0xdeadbee;
3361     action = 0xdeadbee;
3362     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3363     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3364     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3365     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3366
3367     state = 0xdeadbee;
3368     action = 0xdeadbee;
3369     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3370     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3371     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3372     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3373
3374     state = 0xdeadbee;
3375     action = 0xdeadbee;
3376     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3377     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3378     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3379     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3380
3381     state = 0xdeadbee;
3382     action = 0xdeadbee;
3383     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3384     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3385     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3386     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3387
3388     state = 0xdeadbee;
3389     action = 0xdeadbee;
3390     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3391     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3392     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3393     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3394
3395     state = 0xdeadbee;
3396     action = 0xdeadbee;
3397     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3398     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3399     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3400     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3401
3402     state = 0xdeadbee;
3403     action = 0xdeadbee;
3404     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3405     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3406     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3407     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3408
3409     state = 0xdeadbee;
3410     action = 0xdeadbee;
3411     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3412     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3413     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3414     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3415
3416     state = 0xdeadbee;
3417     action = 0xdeadbee;
3418     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3419     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3420     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3421     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3422
3423     state = 0xdeadbee;
3424     action = 0xdeadbee;
3425     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3426     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3427     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3428     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3429
3430     state = 0xdeadbee;
3431     action = 0xdeadbee;
3432     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3433     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3434     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3435     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3436
3437     state = 0xdeadbee;
3438     action = 0xdeadbee;
3439     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3440     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3441     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3442     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3443
3444     state = 0xdeadbee;
3445     action = 0xdeadbee;
3446     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3448     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3449     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3450
3451     state = 0xdeadbee;
3452     action = 0xdeadbee;
3453     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3455     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3456     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3457
3458     state = 0xdeadbee;
3459     action = 0xdeadbee;
3460     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3461     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3462     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3463     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3464
3465     state = 0xdeadbee;
3466     action = 0xdeadbee;
3467     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3468     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3469     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3470     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3471
3472     state = 0xdeadbee;
3473     action = 0xdeadbee;
3474     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3475     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3476     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3477     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3478
3479     state = 0xdeadbee;
3480     action = 0xdeadbee;
3481     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3482     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3483     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3484     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3485
3486     state = 0xdeadbee;
3487     action = 0xdeadbee;
3488     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3489     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3490     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3491     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3492
3493     state = 0xdeadbee;
3494     action = 0xdeadbee;
3495     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3496     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3497     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3498     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3499
3500     state = 0xdeadbee;
3501     action = 0xdeadbee;
3502     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3503     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3504     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3505     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3506
3507     state = 0xdeadbee;
3508     action = 0xdeadbee;
3509     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3510     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3511     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3512     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3513
3514     state = 0xdeadbee;
3515     action = 0xdeadbee;
3516     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3517     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3518     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3519     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3520
3521     state = 0xdeadbee;
3522     action = 0xdeadbee;
3523     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3524     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3525     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3526     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3527
3528     state = 0xdeadbee;
3529     action = 0xdeadbee;
3530     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3531     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3532     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3533     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3534
3535     state = 0xdeadbee;
3536     action = 0xdeadbee;
3537     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3538     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3539     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3540     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3541
3542     state = 0xdeadbee;
3543     action = 0xdeadbee;
3544     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3545     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3546     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3547     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3548
3549     MsiCloseHandle( hpkg );
3550
3551     /* publish the features and components */
3552     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3553     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3554
3555     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3556     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3557
3558     /* these properties must not be in the saved msi file */
3559     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3560     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3561
3562     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3563     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3564
3565     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3566     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3567
3568     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3569     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3570
3571     hpkg = package_from_db( hdb );
3572     ok( hpkg, "failed to create package\n");
3573
3574     MsiCloseHandle(hdb);
3575
3576     state = 0xdeadbee;
3577     action = 0xdeadbee;
3578     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3579     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3580     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3581     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3582
3583     state = 0xdeadbee;
3584     action = 0xdeadbee;
3585     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3586     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3587     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3588     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3589
3590     state = 0xdeadbee;
3591     action = 0xdeadbee;
3592     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3593     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3594     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3595     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3596
3597     state = 0xdeadbee;
3598     action = 0xdeadbee;
3599     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3600     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3601     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3602     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3603
3604     state = 0xdeadbee;
3605     action = 0xdeadbee;
3606     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3607     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3608     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3609     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3610
3611     state = 0xdeadbee;
3612     action = 0xdeadbee;
3613     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3614     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3615     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3616     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3617
3618     state = 0xdeadbee;
3619     action = 0xdeadbee;
3620     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3621     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3622     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3623     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3624
3625     state = 0xdeadbee;
3626     action = 0xdeadbee;
3627     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3628     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3629     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3630     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3631
3632     state = 0xdeadbee;
3633     action = 0xdeadbee;
3634     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3635     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3636     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3637     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3638
3639     state = 0xdeadbee;
3640     action = 0xdeadbee;
3641     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3642     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3643     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3644     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3645
3646     state = 0xdeadbee;
3647     action = 0xdeadbee;
3648     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3649     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3650     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3651     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3652
3653     state = 0xdeadbee;
3654     action = 0xdeadbee;
3655     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3656     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3657     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3658     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3659
3660     state = 0xdeadbee;
3661     action = 0xdeadbee;
3662     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3663     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3664     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3665     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3666
3667     state = 0xdeadbee;
3668     action = 0xdeadbee;
3669     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3670     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3671     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3672     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3673
3674     state = 0xdeadbee;
3675     action = 0xdeadbee;
3676     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3677     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3678     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3679     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3680
3681     state = 0xdeadbee;
3682     action = 0xdeadbee;
3683     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3684     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3685     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3686     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3687
3688     state = 0xdeadbee;
3689     action = 0xdeadbee;
3690     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3691     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3692     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3693     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3694
3695     state = 0xdeadbee;
3696     action = 0xdeadbee;
3697     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3698     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3699     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3700     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3701
3702     state = 0xdeadbee;
3703     action = 0xdeadbee;
3704     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3705     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3706     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3707     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3708
3709     state = 0xdeadbee;
3710     action = 0xdeadbee;
3711     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3712     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3713     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3714     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3715
3716     state = 0xdeadbee;
3717     action = 0xdeadbee;
3718     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3719     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3720     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3721     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3722
3723     state = 0xdeadbee;
3724     action = 0xdeadbee;
3725     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3726     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3727     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3728     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3729
3730     state = 0xdeadbee;
3731     action = 0xdeadbee;
3732     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3733     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3734     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3735     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3736
3737     state = 0xdeadbee;
3738     action = 0xdeadbee;
3739     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3740     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3741     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3742     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3743
3744     state = 0xdeadbee;
3745     action = 0xdeadbee;
3746     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3747     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3748     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3749     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3750
3751     state = 0xdeadbee;
3752     action = 0xdeadbee;
3753     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3754     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3755     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3756     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3757
3758     state = 0xdeadbee;
3759     action = 0xdeadbee;
3760     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3761     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3762     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3763     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3764
3765     state = 0xdeadbee;
3766     action = 0xdeadbee;
3767     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3768     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3769     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3770     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3771
3772     state = 0xdeadbee;
3773     action = 0xdeadbee;
3774     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3775     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3776     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3777     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3778
3779     state = 0xdeadbee;
3780     action = 0xdeadbee;
3781     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3782     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3783     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3784     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3785
3786     state = 0xdeadbee;
3787     action = 0xdeadbee;
3788     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3789     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3790     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3791     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3792
3793     r = MsiDoAction( hpkg, "CostInitialize");
3794     ok( r == ERROR_SUCCESS, "cost init failed\n");
3795
3796     state = 0xdeadbee;
3797     action = 0xdeadbee;
3798     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3799     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3800     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3801     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3802
3803     state = 0xdeadbee;
3804     action = 0xdeadbee;
3805     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3806     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3807     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3808     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3809
3810     state = 0xdeadbee;
3811     action = 0xdeadbee;
3812     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3813     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3814     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3815     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3816
3817     state = 0xdeadbee;
3818     action = 0xdeadbee;
3819     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3820     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3821     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3822     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3823
3824     state = 0xdeadbee;
3825     action = 0xdeadbee;
3826     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3827     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3828     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3829     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3830
3831     state = 0xdeadbee;
3832     action = 0xdeadbee;
3833     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3834     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3835     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3836     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3837
3838     state = 0xdeadbee;
3839     action = 0xdeadbee;
3840     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3841     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3842     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3843     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3844
3845     state = 0xdeadbee;
3846     action = 0xdeadbee;
3847     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3848     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3849     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3850     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3851
3852     state = 0xdeadbee;
3853     action = 0xdeadbee;
3854     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3855     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3856     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3857     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3858
3859     state = 0xdeadbee;
3860     action = 0xdeadbee;
3861     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3862     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3863     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3864     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3865
3866     state = 0xdeadbee;
3867     action = 0xdeadbee;
3868     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3869     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3870     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3871     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3872
3873     state = 0xdeadbee;
3874     action = 0xdeadbee;
3875     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3876     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3877     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3878     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3879
3880     state = 0xdeadbee;
3881     action = 0xdeadbee;
3882     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3883     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3884     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3885     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3886
3887     state = 0xdeadbee;
3888     action = 0xdeadbee;
3889     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3890     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3891     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3892     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3893
3894     state = 0xdeadbee;
3895     action = 0xdeadbee;
3896     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3897     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3898     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3899     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3900
3901     state = 0xdeadbee;
3902     action = 0xdeadbee;
3903     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3904     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3905     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3906     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3907
3908     state = 0xdeadbee;
3909     action = 0xdeadbee;
3910     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3911     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3912     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3913     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3914
3915     state = 0xdeadbee;
3916     action = 0xdeadbee;
3917     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3918     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3919     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3920     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3921
3922     state = 0xdeadbee;
3923     action = 0xdeadbee;
3924     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3925     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3926     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3927     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3928
3929     state = 0xdeadbee;
3930     action = 0xdeadbee;
3931     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3932     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3933     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3934     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3935
3936     state = 0xdeadbee;
3937     action = 0xdeadbee;
3938     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3939     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3940     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3941     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3942
3943     state = 0xdeadbee;
3944     action = 0xdeadbee;
3945     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3946     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3947     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3948     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3949
3950     state = 0xdeadbee;
3951     action = 0xdeadbee;
3952     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3953     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3954     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3955     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3956
3957     state = 0xdeadbee;
3958     action = 0xdeadbee;
3959     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3960     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3961     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3962     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3963
3964     state = 0xdeadbee;
3965     action = 0xdeadbee;
3966     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3967     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3968     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3969     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3970
3971     state = 0xdeadbee;
3972     action = 0xdeadbee;
3973     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3974     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3975     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3976     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3977
3978     state = 0xdeadbee;
3979     action = 0xdeadbee;
3980     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3981     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3982     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3983     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3984
3985     state = 0xdeadbee;
3986     action = 0xdeadbee;
3987     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3988     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3989     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3990     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3991
3992     state = 0xdeadbee;
3993     action = 0xdeadbee;
3994     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3996     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3997     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3998
3999     state = 0xdeadbee;
4000     action = 0xdeadbee;
4001     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4002     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4003     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4004     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4005
4006     state = 0xdeadbee;
4007     action = 0xdeadbee;
4008     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4009     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4010     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4011     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4012
4013     r = MsiDoAction( hpkg, "FileCost");
4014     ok( r == ERROR_SUCCESS, "file cost failed\n");
4015
4016     state = 0xdeadbee;
4017     action = 0xdeadbee;
4018     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4019     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4020     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4021     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4022
4023     state = 0xdeadbee;
4024     action = 0xdeadbee;
4025     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4026     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4027     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4028     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4029
4030     state = 0xdeadbee;
4031     action = 0xdeadbee;
4032     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4034     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4035     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4036
4037     state = 0xdeadbee;
4038     action = 0xdeadbee;
4039     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4040     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4041     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4042     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4043
4044     state = 0xdeadbee;
4045     action = 0xdeadbee;
4046     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4047     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4048     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4049     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4050
4051     state = 0xdeadbee;
4052     action = 0xdeadbee;
4053     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4055     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4056     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4057
4058     state = 0xdeadbee;
4059     action = 0xdeadbee;
4060     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4061     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4062     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4063     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4064
4065     state = 0xdeadbee;
4066     action = 0xdeadbee;
4067     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4068     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4069     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4070     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4071
4072     state = 0xdeadbee;
4073     action = 0xdeadbee;
4074     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4075     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4076     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4077     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4078
4079     state = 0xdeadbee;
4080     action = 0xdeadbee;
4081     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4082     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4083     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4084     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4085
4086     state = 0xdeadbee;
4087     action = 0xdeadbee;
4088     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4089     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4090     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4091     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4092
4093     state = 0xdeadbee;
4094     action = 0xdeadbee;
4095     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4096     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4097     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4098     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4099
4100     state = 0xdeadbee;
4101     action = 0xdeadbee;
4102     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4103     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4104     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4105     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4106
4107     state = 0xdeadbee;
4108     action = 0xdeadbee;
4109     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4110     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4111     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4112     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4113
4114     state = 0xdeadbee;
4115     action = 0xdeadbee;
4116     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4118     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4119     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4120
4121     state = 0xdeadbee;
4122     action = 0xdeadbee;
4123     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4124     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4125     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4126     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4127
4128     state = 0xdeadbee;
4129     action = 0xdeadbee;
4130     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4131     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4132     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4133     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4134
4135     state = 0xdeadbee;
4136     action = 0xdeadbee;
4137     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4138     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4139     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4140     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4141
4142     state = 0xdeadbee;
4143     action = 0xdeadbee;
4144     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4146     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4147     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4148
4149     state = 0xdeadbee;
4150     action = 0xdeadbee;
4151     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4152     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4153     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4154     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4155
4156     state = 0xdeadbee;
4157     action = 0xdeadbee;
4158     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4160     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4161     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4162
4163     state = 0xdeadbee;
4164     action = 0xdeadbee;
4165     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4167     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4168     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4169
4170     state = 0xdeadbee;
4171     action = 0xdeadbee;
4172     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4174     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4175     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4176
4177     state = 0xdeadbee;
4178     action = 0xdeadbee;
4179     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4181     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4182     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4183
4184     state = 0xdeadbee;
4185     action = 0xdeadbee;
4186     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4188     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4189     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4190
4191     state = 0xdeadbee;
4192     action = 0xdeadbee;
4193     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4195     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4196     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4197
4198     state = 0xdeadbee;
4199     action = 0xdeadbee;
4200     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4202     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4203     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4204
4205     state = 0xdeadbee;
4206     action = 0xdeadbee;
4207     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4209     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4210     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4211
4212     state = 0xdeadbee;
4213     action = 0xdeadbee;
4214     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4216     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4217     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4218
4219     state = 0xdeadbee;
4220     action = 0xdeadbee;
4221     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4223     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4224     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4225
4226     r = MsiDoAction( hpkg, "CostFinalize");
4227     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4228
4229     state = 0xdeadbee;
4230     action = 0xdeadbee;
4231     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4232     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4233     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4234     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4235
4236     state = 0xdeadbee;
4237     action = 0xdeadbee;
4238     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4239     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4240     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4241     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4242
4243     state = 0xdeadbee;
4244     action = 0xdeadbee;
4245     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4246     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4247     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4248     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4249
4250     state = 0xdeadbee;
4251     action = 0xdeadbee;
4252     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4253     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4254     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4255     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4256
4257     state = 0xdeadbee;
4258     action = 0xdeadbee;
4259     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4260     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4261     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4262     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4263
4264     state = 0xdeadbee;
4265     action = 0xdeadbee;
4266     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4267     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4268     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4269     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4270
4271     state = 0xdeadbee;
4272     action = 0xdeadbee;
4273     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4274     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4275     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4276     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4277
4278     state = 0xdeadbee;
4279     action = 0xdeadbee;
4280     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4281     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4282     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4283     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4284
4285     state = 0xdeadbee;
4286     action = 0xdeadbee;
4287     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4288     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4289     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4290     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4291
4292     state = 0xdeadbee;
4293     action = 0xdeadbee;
4294     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4295     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4296     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4297     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4298
4299     state = 0xdeadbee;
4300     action = 0xdeadbee;
4301     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4302     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4303     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4304     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4305
4306     state = 0xdeadbee;
4307     action = 0xdeadbee;
4308     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4309     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4310     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4311     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4312
4313     state = 0xdeadbee;
4314     action = 0xdeadbee;
4315     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4316     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4317     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4318     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4319
4320     state = 0xdeadbee;
4321     action = 0xdeadbee;
4322     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4323     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4324     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4325     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4326
4327     state = 0xdeadbee;
4328     action = 0xdeadbee;
4329     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4330     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4331     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4332     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4333
4334     state = 0xdeadbee;
4335     action = 0xdeadbee;
4336     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4337     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4338     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4339     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4340
4341     state = 0xdeadbee;
4342     action = 0xdeadbee;
4343     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4344     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4345     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4346     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4347
4348     state = 0xdeadbee;
4349     action = 0xdeadbee;
4350     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4351     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4352     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4353     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4354
4355     state = 0xdeadbee;
4356     action = 0xdeadbee;
4357     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4358     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4359     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4360     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4361
4362     state = 0xdeadbee;
4363     action = 0xdeadbee;
4364     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4365     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4366     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4367     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4368
4369     state = 0xdeadbee;
4370     action = 0xdeadbee;
4371     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4372     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4373     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4374     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4375
4376     state = 0xdeadbee;
4377     action = 0xdeadbee;
4378     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4379     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4380     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4381     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4382
4383     state = 0xdeadbee;
4384     action = 0xdeadbee;
4385     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4386     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4387     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4388     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4389
4390     state = 0xdeadbee;
4391     action = 0xdeadbee;
4392     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4393     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4394     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4395     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4396
4397     state = 0xdeadbee;
4398     action = 0xdeadbee;
4399     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4400     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4401     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4402     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4403
4404     state = 0xdeadbee;
4405     action = 0xdeadbee;
4406     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4407     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4408     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4409     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4410
4411     state = 0xdeadbee;
4412     action = 0xdeadbee;
4413     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4414     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4415     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4416     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4417
4418     state = 0xdeadbee;
4419     action = 0xdeadbee;
4420     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4421     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4422     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4423     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4424
4425     state = 0xdeadbee;
4426     action = 0xdeadbee;
4427     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4428     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4429     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4430     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4431
4432     state = 0xdeadbee;
4433     action = 0xdeadbee;
4434     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4435     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4436     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4437     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4438
4439     state = 0xdeadbee;
4440     action = 0xdeadbee;
4441     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4442     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4443     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4444     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4445
4446     MsiCloseHandle(hpkg);
4447
4448     /* uninstall the product */
4449     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4451
4452     /* all features installed locally */
4453     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4455
4456     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4457     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4458
4459     /* these properties must not be in the saved msi file */
4460     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4461     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4462
4463     hpkg = package_from_db( hdb );
4464     ok( hpkg, "failed to create package\n");
4465
4466     state = 0xdeadbee;
4467     action = 0xdeadbee;
4468     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4469     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4470     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4471     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4472
4473     state = 0xdeadbee;
4474     action = 0xdeadbee;
4475     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4476     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4477     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4478     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4479
4480     state = 0xdeadbee;
4481     action = 0xdeadbee;
4482     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4483     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4484     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4485     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4486
4487     state = 0xdeadbee;
4488     action = 0xdeadbee;
4489     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4490     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4491     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4492     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4493
4494     state = 0xdeadbee;
4495     action = 0xdeadbee;
4496     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4497     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4498     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4499     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4500
4501     state = 0xdeadbee;
4502     action = 0xdeadbee;
4503     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4504     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4505     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4506     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4507
4508     state = 0xdeadbee;
4509     action = 0xdeadbee;
4510     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4511     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4512     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4513     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4514
4515     state = 0xdeadbee;
4516     action = 0xdeadbee;
4517     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4518     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4519     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4520     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4521
4522     state = 0xdeadbee;
4523     action = 0xdeadbee;
4524     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4525     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4526     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4527     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4528
4529     state = 0xdeadbee;
4530     action = 0xdeadbee;
4531     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4532     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4533     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4534     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4535
4536     state = 0xdeadbee;
4537     action = 0xdeadbee;
4538     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4539     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4540     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4541     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4542
4543     state = 0xdeadbee;
4544     action = 0xdeadbee;
4545     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4546     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4547     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4548     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4549
4550     state = 0xdeadbee;
4551     action = 0xdeadbee;
4552     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4553     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4554     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4555     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4556
4557     state = 0xdeadbee;
4558     action = 0xdeadbee;
4559     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4560     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4561     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4562     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4563
4564     state = 0xdeadbee;
4565     action = 0xdeadbee;
4566     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4567     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4568     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4569     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4570
4571     state = 0xdeadbee;
4572     action = 0xdeadbee;
4573     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4574     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4575     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4576     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4577
4578     state = 0xdeadbee;
4579     action = 0xdeadbee;
4580     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4581     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4582     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4583     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4584
4585     state = 0xdeadbee;
4586     action = 0xdeadbee;
4587     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4588     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4589     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4590     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4591
4592     state = 0xdeadbee;
4593     action = 0xdeadbee;
4594     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4595     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4596     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4597     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4598
4599     state = 0xdeadbee;
4600     action = 0xdeadbee;
4601     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4602     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4603     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4604     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4605
4606     state = 0xdeadbee;
4607     action = 0xdeadbee;
4608     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4609     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4610     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4611     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4612
4613     state = 0xdeadbee;
4614     action = 0xdeadbee;
4615     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4616     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4617     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4618     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4619
4620     state = 0xdeadbee;
4621     action = 0xdeadbee;
4622     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4623     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4624     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4625     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4626
4627     state = 0xdeadbee;
4628     action = 0xdeadbee;
4629     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4630     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4631     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4632     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4633
4634     state = 0xdeadbee;
4635     action = 0xdeadbee;
4636     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4637     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4638     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4639     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4640
4641     state = 0xdeadbee;
4642     action = 0xdeadbee;
4643     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4644     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4645     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4646     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4647
4648     state = 0xdeadbee;
4649     action = 0xdeadbee;
4650     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4651     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4652     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4653     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4654
4655     state = 0xdeadbee;
4656     action = 0xdeadbee;
4657     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4658     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4659     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4660     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4661
4662     state = 0xdeadbee;
4663     action = 0xdeadbee;
4664     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4665     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4666     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4667     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4668
4669     state = 0xdeadbee;
4670     action = 0xdeadbee;
4671     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4672     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4673     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4674     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4675
4676     state = 0xdeadbee;
4677     action = 0xdeadbee;
4678     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4679     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4680     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4681     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4682
4683     r = MsiDoAction( hpkg, "CostInitialize");
4684     ok( r == ERROR_SUCCESS, "cost init failed\n");
4685
4686     state = 0xdeadbee;
4687     action = 0xdeadbee;
4688     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4689     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4690     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4691     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4692
4693     state = 0xdeadbee;
4694     action = 0xdeadbee;
4695     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4696     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4697     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4698     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4699
4700     state = 0xdeadbee;
4701     action = 0xdeadbee;
4702     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4703     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4704     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4705     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4706
4707     state = 0xdeadbee;
4708     action = 0xdeadbee;
4709     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4710     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4711     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4712     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4713
4714     state = 0xdeadbee;
4715     action = 0xdeadbee;
4716     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4717     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4718     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4719     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4720
4721     state = 0xdeadbee;
4722     action = 0xdeadbee;
4723     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4724     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4725     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4726     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4727
4728     state = 0xdeadbee;
4729     action = 0xdeadbee;
4730     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4731     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4732     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4733     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4734
4735     state = 0xdeadbee;
4736     action = 0xdeadbee;
4737     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4738     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4739     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4740     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4741
4742     state = 0xdeadbee;
4743     action = 0xdeadbee;
4744     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4745     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4746     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4747     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4748
4749     state = 0xdeadbee;
4750     action = 0xdeadbee;
4751     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4752     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4753     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4754     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4755
4756     state = 0xdeadbee;
4757     action = 0xdeadbee;
4758     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4759     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4760     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4761     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4762
4763     state = 0xdeadbee;
4764     action = 0xdeadbee;
4765     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4766     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4767     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4768     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4769
4770     state = 0xdeadbee;
4771     action = 0xdeadbee;
4772     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4773     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4774     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4775     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4776
4777     state = 0xdeadbee;
4778     action = 0xdeadbee;
4779     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4780     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4781     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4782     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4783
4784     state = 0xdeadbee;
4785     action = 0xdeadbee;
4786     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4787     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4788     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4789     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4790
4791     state = 0xdeadbee;
4792     action = 0xdeadbee;
4793     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4794     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4795     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4796     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4797
4798     state = 0xdeadbee;
4799     action = 0xdeadbee;
4800     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4801     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4802     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4803     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4804
4805     state = 0xdeadbee;
4806     action = 0xdeadbee;
4807     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4808     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4809     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4810     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4811
4812     state = 0xdeadbee;
4813     action = 0xdeadbee;
4814     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4815     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4816     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4817     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4818
4819     state = 0xdeadbee;
4820     action = 0xdeadbee;
4821     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4822     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4823     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4824     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4825
4826     state = 0xdeadbee;
4827     action = 0xdeadbee;
4828     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4829     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4830     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4831     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4832
4833     state = 0xdeadbee;
4834     action = 0xdeadbee;
4835     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4836     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4837     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4838     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4839
4840     state = 0xdeadbee;
4841     action = 0xdeadbee;
4842     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4843     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4844     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4845     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4846
4847     state = 0xdeadbee;
4848     action = 0xdeadbee;
4849     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4850     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4851     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4852     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4853
4854     state = 0xdeadbee;
4855     action = 0xdeadbee;
4856     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4857     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4858     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4859     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4860
4861     state = 0xdeadbee;
4862     action = 0xdeadbee;
4863     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4864     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4865     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4866     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4867
4868     state = 0xdeadbee;
4869     action = 0xdeadbee;
4870     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4871     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4872     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4873     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4874
4875     state = 0xdeadbee;
4876     action = 0xdeadbee;
4877     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4878     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4879     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4880     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4881
4882     state = 0xdeadbee;
4883     action = 0xdeadbee;
4884     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4885     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4886     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4887     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4888
4889     state = 0xdeadbee;
4890     action = 0xdeadbee;
4891     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4892     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4893     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4894     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4895
4896     state = 0xdeadbee;
4897     action = 0xdeadbee;
4898     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4899     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4900     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4901     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4902
4903     r = MsiDoAction( hpkg, "FileCost");
4904     ok( r == ERROR_SUCCESS, "file cost failed\n");
4905
4906     state = 0xdeadbee;
4907     action = 0xdeadbee;
4908     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4909     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4910     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4911     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4912
4913     state = 0xdeadbee;
4914     action = 0xdeadbee;
4915     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4916     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4917     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4918     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4919
4920     state = 0xdeadbee;
4921     action = 0xdeadbee;
4922     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4923     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4924     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4925     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4926
4927     state = 0xdeadbee;
4928     action = 0xdeadbee;
4929     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4930     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4931     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4932     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4933
4934     state = 0xdeadbee;
4935     action = 0xdeadbee;
4936     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4937     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4938     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4939     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4940
4941     state = 0xdeadbee;
4942     action = 0xdeadbee;
4943     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4944     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4945     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4946     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4947
4948     state = 0xdeadbee;
4949     action = 0xdeadbee;
4950     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4951     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4952     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4953     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4954
4955     state = 0xdeadbee;
4956     action = 0xdeadbee;
4957     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4958     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4959     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4960     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4961
4962     state = 0xdeadbee;
4963     action = 0xdeadbee;
4964     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4965     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4966     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4967     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4968
4969     state = 0xdeadbee;
4970     action = 0xdeadbee;
4971     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4972     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4973     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4974     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4975
4976     state = 0xdeadbee;
4977     action = 0xdeadbee;
4978     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4979     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4980     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4981     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4982
4983     state = 0xdeadbee;
4984     action = 0xdeadbee;
4985     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4986     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4987     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4988     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4989
4990     state = 0xdeadbee;
4991     action = 0xdeadbee;
4992     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4993     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4994     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4995     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4996
4997     state = 0xdeadbee;
4998     action = 0xdeadbee;
4999     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5000     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5001     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5002     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5003
5004     state = 0xdeadbee;
5005     action = 0xdeadbee;
5006     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5007     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5008     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5009     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5010
5011     state = 0xdeadbee;
5012     action = 0xdeadbee;
5013     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5014     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5015     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5016     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5017
5018     state = 0xdeadbee;
5019     action = 0xdeadbee;
5020     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5021     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5022     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5023     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5024
5025     state = 0xdeadbee;
5026     action = 0xdeadbee;
5027     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5028     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5029     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5030     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5031
5032     state = 0xdeadbee;
5033     action = 0xdeadbee;
5034     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5035     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5036     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5037     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5038
5039     state = 0xdeadbee;
5040     action = 0xdeadbee;
5041     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5042     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5043     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5044     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5045
5046     state = 0xdeadbee;
5047     action = 0xdeadbee;
5048     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5049     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5050     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5051     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5052
5053     state = 0xdeadbee;
5054     action = 0xdeadbee;
5055     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5056     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5057     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5058     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5059
5060     state = 0xdeadbee;
5061     action = 0xdeadbee;
5062     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5063     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5064     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5065     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5066
5067     state = 0xdeadbee;
5068     action = 0xdeadbee;
5069     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5070     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5071     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5072     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5073
5074     state = 0xdeadbee;
5075     action = 0xdeadbee;
5076     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5080
5081     state = 0xdeadbee;
5082     action = 0xdeadbee;
5083     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5087
5088     state = 0xdeadbee;
5089     action = 0xdeadbee;
5090     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5094
5095     state = 0xdeadbee;
5096     action = 0xdeadbee;
5097     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5101
5102     state = 0xdeadbee;
5103     action = 0xdeadbee;
5104     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5108
5109     state = 0xdeadbee;
5110     action = 0xdeadbee;
5111     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5115
5116     state = 0xdeadbee;
5117     action = 0xdeadbee;
5118     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5122
5123     r = MsiDoAction( hpkg, "CostFinalize");
5124     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5125
5126     state = 0xdeadbee;
5127     action = 0xdeadbee;
5128     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5129     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5130     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5131     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5132
5133     state = 0xdeadbee;
5134     action = 0xdeadbee;
5135     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5136     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5137     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5138     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5139
5140     state = 0xdeadbee;
5141     action = 0xdeadbee;
5142     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5143     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5144     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5145     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5146
5147     state = 0xdeadbee;
5148     action = 0xdeadbee;
5149     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5150     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5151     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5152     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5153
5154     state = 0xdeadbee;
5155     action = 0xdeadbee;
5156     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5157     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5158     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5159     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5160
5161     state = 0xdeadbee;
5162     action = 0xdeadbee;
5163     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5164     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5165     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5166     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5167
5168     state = 0xdeadbee;
5169     action = 0xdeadbee;
5170     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5171     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5172     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5173     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5174
5175     state = 0xdeadbee;
5176     action = 0xdeadbee;
5177     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5178     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5179     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5180     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5181
5182     state = 0xdeadbee;
5183     action = 0xdeadbee;
5184     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5185     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5186     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5187     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5188
5189     state = 0xdeadbee;
5190     action = 0xdeadbee;
5191     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5192     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5193     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5194     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5195
5196     state = 0xdeadbee;
5197     action = 0xdeadbee;
5198     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5199     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5200     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5201     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5202
5203     state = 0xdeadbee;
5204     action = 0xdeadbee;
5205     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5206     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5207     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5208     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5209
5210     state = 0xdeadbee;
5211     action = 0xdeadbee;
5212     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5213     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5214     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5215     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5216
5217     state = 0xdeadbee;
5218     action = 0xdeadbee;
5219     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5220     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5221     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5222     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5223
5224     state = 0xdeadbee;
5225     action = 0xdeadbee;
5226     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5227     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5228     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5229     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5230
5231     state = 0xdeadbee;
5232     action = 0xdeadbee;
5233     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5234     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5235     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5236     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5237
5238     state = 0xdeadbee;
5239     action = 0xdeadbee;
5240     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5241     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5242     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5243     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5244
5245     state = 0xdeadbee;
5246     action = 0xdeadbee;
5247     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5248     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5249     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5250     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5251
5252     state = 0xdeadbee;
5253     action = 0xdeadbee;
5254     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5255     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5256     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5257     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5258
5259     state = 0xdeadbee;
5260     action = 0xdeadbee;
5261     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5262     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5263     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5264     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5265
5266     state = 0xdeadbee;
5267     action = 0xdeadbee;
5268     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5269     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5270     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5271     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5272
5273     state = 0xdeadbee;
5274     action = 0xdeadbee;
5275     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5276     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5277     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5278     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5279
5280     state = 0xdeadbee;
5281     action = 0xdeadbee;
5282     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5283     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5284     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5285     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5286
5287     state = 0xdeadbee;
5288     action = 0xdeadbee;
5289     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5290     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5291     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5292     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5293
5294     state = 0xdeadbee;
5295     action = 0xdeadbee;
5296     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5297     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5298     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5299     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5300
5301     state = 0xdeadbee;
5302     action = 0xdeadbee;
5303     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5304     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5305     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5306     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5307
5308     state = 0xdeadbee;
5309     action = 0xdeadbee;
5310     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5312     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5313     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5314
5315     state = 0xdeadbee;
5316     action = 0xdeadbee;
5317     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5319     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5320     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5321
5322     state = 0xdeadbee;
5323     action = 0xdeadbee;
5324     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5326     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5327     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5328
5329     state = 0xdeadbee;
5330     action = 0xdeadbee;
5331     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5333     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5334     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5335
5336     state = 0xdeadbee;
5337     action = 0xdeadbee;
5338     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5340     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5341     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5342
5343     MsiCloseHandle(hpkg);
5344
5345     /* uninstall the product */
5346     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5347     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5348
5349     /* all features installed from source */
5350     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5351     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5352
5353     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5354     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5355
5356     /* this property must not be in the saved msi file */
5357     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5358     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5359
5360     hpkg = package_from_db( hdb );
5361     ok( hpkg, "failed to create package\n");
5362
5363     state = 0xdeadbee;
5364     action = 0xdeadbee;
5365     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5366     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5367     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5368     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5369
5370     state = 0xdeadbee;
5371     action = 0xdeadbee;
5372     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5373     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5374     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5375     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5376
5377     state = 0xdeadbee;
5378     action = 0xdeadbee;
5379     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5380     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5381     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5382     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5383
5384     state = 0xdeadbee;
5385     action = 0xdeadbee;
5386     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5387     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5388     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5389     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5390
5391     state = 0xdeadbee;
5392     action = 0xdeadbee;
5393     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5394     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5395     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5396     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5397
5398     state = 0xdeadbee;
5399     action = 0xdeadbee;
5400     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5401     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5402     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5403     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5404
5405     state = 0xdeadbee;
5406     action = 0xdeadbee;
5407     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5408     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5409     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5410     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5411
5412     state = 0xdeadbee;
5413     action = 0xdeadbee;
5414     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5415     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5416     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5417     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5418
5419     state = 0xdeadbee;
5420     action = 0xdeadbee;
5421     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5422     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5423     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5424     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5425
5426     state = 0xdeadbee;
5427     action = 0xdeadbee;
5428     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5429     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5430     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5431     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5432
5433     state = 0xdeadbee;
5434     action = 0xdeadbee;
5435     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5436     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5437     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5438     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5439
5440     state = 0xdeadbee;
5441     action = 0xdeadbee;
5442     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5443     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5444     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5445     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5446
5447     state = 0xdeadbee;
5448     action = 0xdeadbee;
5449     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5450     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5451     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5452     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5453
5454     state = 0xdeadbee;
5455     action = 0xdeadbee;
5456     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5457     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5458     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5459     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5460
5461     state = 0xdeadbee;
5462     action = 0xdeadbee;
5463     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5464     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5465     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5466     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5467
5468     state = 0xdeadbee;
5469     action = 0xdeadbee;
5470     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5471     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5472     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5473     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5474
5475     state = 0xdeadbee;
5476     action = 0xdeadbee;
5477     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5478     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5479     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5480     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5481
5482     state = 0xdeadbee;
5483     action = 0xdeadbee;
5484     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5485     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5486     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5487     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5488
5489     state = 0xdeadbee;
5490     action = 0xdeadbee;
5491     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5492     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5493     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5494     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5495
5496     state = 0xdeadbee;
5497     action = 0xdeadbee;
5498     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5499     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5500     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5501     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5502
5503     state = 0xdeadbee;
5504     action = 0xdeadbee;
5505     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5506     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5507     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5508     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5509
5510     state = 0xdeadbee;
5511     action = 0xdeadbee;
5512     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5513     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5514     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5515     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5516
5517     state = 0xdeadbee;
5518     action = 0xdeadbee;
5519     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5520     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5521     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5522     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5523
5524     state = 0xdeadbee;
5525     action = 0xdeadbee;
5526     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5527     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5528     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5529     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5530
5531     state = 0xdeadbee;
5532     action = 0xdeadbee;
5533     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5534     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5535     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5536     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5537
5538     state = 0xdeadbee;
5539     action = 0xdeadbee;
5540     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5541     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5542     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5543     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5544
5545     state = 0xdeadbee;
5546     action = 0xdeadbee;
5547     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5548     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5549     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5550     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5551
5552     state = 0xdeadbee;
5553     action = 0xdeadbee;
5554     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5555     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5556     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5557     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5558
5559     state = 0xdeadbee;
5560     action = 0xdeadbee;
5561     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5562     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5563     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5564     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5565
5566     state = 0xdeadbee;
5567     action = 0xdeadbee;
5568     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5569     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5570     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5571     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5572
5573     state = 0xdeadbee;
5574     action = 0xdeadbee;
5575     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5576     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5577     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5578     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5579
5580     r = MsiDoAction( hpkg, "CostInitialize");
5581     ok( r == ERROR_SUCCESS, "cost init failed\n");
5582
5583     state = 0xdeadbee;
5584     action = 0xdeadbee;
5585     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5586     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5587     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5588     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5589
5590     state = 0xdeadbee;
5591     action = 0xdeadbee;
5592     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5593     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5594     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5595     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5596
5597     state = 0xdeadbee;
5598     action = 0xdeadbee;
5599     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5600     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5601     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5602     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5603
5604     state = 0xdeadbee;
5605     action = 0xdeadbee;
5606     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5607     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5608     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5609     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5610
5611     state = 0xdeadbee;
5612     action = 0xdeadbee;
5613     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5614     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5615     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5616     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5617
5618     state = 0xdeadbee;
5619     action = 0xdeadbee;
5620     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5621     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5622     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5623     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5624
5625     state = 0xdeadbee;
5626     action = 0xdeadbee;
5627     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5628     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5629     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5630     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5631
5632     state = 0xdeadbee;
5633     action = 0xdeadbee;
5634     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5635     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5636     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5637     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5638
5639     state = 0xdeadbee;
5640     action = 0xdeadbee;
5641     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5642     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5643     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5644     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5645
5646     state = 0xdeadbee;
5647     action = 0xdeadbee;
5648     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5649     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5650     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5651     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5652
5653     state = 0xdeadbee;
5654     action = 0xdeadbee;
5655     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5656     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5657     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5658     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5659
5660     state = 0xdeadbee;
5661     action = 0xdeadbee;
5662     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5663     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5664     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5665     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5666
5667     state = 0xdeadbee;
5668     action = 0xdeadbee;
5669     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5670     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5671     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5672     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5673
5674     state = 0xdeadbee;
5675     action = 0xdeadbee;
5676     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5677     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5678     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5679     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5680
5681     state = 0xdeadbee;
5682     action = 0xdeadbee;
5683     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5684     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5685     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5686     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5687
5688     state = 0xdeadbee;
5689     action = 0xdeadbee;
5690     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5691     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5692     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5693     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5694
5695     state = 0xdeadbee;
5696     action = 0xdeadbee;
5697     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5698     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5699     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5700     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5701
5702     state = 0xdeadbee;
5703     action = 0xdeadbee;
5704     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5705     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5706     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5707     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5708
5709     state = 0xdeadbee;
5710     action = 0xdeadbee;
5711     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5712     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5713     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5714     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5715
5716     state = 0xdeadbee;
5717     action = 0xdeadbee;
5718     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5719     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5720     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5721     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5722
5723     state = 0xdeadbee;
5724     action = 0xdeadbee;
5725     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5726     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5727     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5728     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5729
5730     state = 0xdeadbee;
5731     action = 0xdeadbee;
5732     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5733     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5734     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5735     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5736
5737     state = 0xdeadbee;
5738     action = 0xdeadbee;
5739     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5740     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5741     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5742     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5743
5744     state = 0xdeadbee;
5745     action = 0xdeadbee;
5746     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5747     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5748     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5749     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5750
5751     state = 0xdeadbee;
5752     action = 0xdeadbee;
5753     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5754     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5755     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5756     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5757
5758     state = 0xdeadbee;
5759     action = 0xdeadbee;
5760     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5761     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5762     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5763     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5764
5765     state = 0xdeadbee;
5766     action = 0xdeadbee;
5767     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5768     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5769     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5770     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5771
5772     state = 0xdeadbee;
5773     action = 0xdeadbee;
5774     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5775     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5776     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5777     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5778
5779     state = 0xdeadbee;
5780     action = 0xdeadbee;
5781     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5782     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5783     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5784     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5785
5786     state = 0xdeadbee;
5787     action = 0xdeadbee;
5788     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5789     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5790     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5791     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5792
5793     state = 0xdeadbee;
5794     action = 0xdeadbee;
5795     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5796     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5797     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5798     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5799
5800     r = MsiDoAction( hpkg, "FileCost");
5801     ok( r == ERROR_SUCCESS, "file cost failed\n");
5802
5803     state = 0xdeadbee;
5804     action = 0xdeadbee;
5805     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5806     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5807     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5808     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5809
5810     state = 0xdeadbee;
5811     action = 0xdeadbee;
5812     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5813     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5814     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5815     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5816
5817     state = 0xdeadbee;
5818     action = 0xdeadbee;
5819     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5820     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5821     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5822     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5823
5824     state = 0xdeadbee;
5825     action = 0xdeadbee;
5826     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5827     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5828     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5829     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5830
5831     state = 0xdeadbee;
5832     action = 0xdeadbee;
5833     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5834     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5835     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5836     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5837
5838     state = 0xdeadbee;
5839     action = 0xdeadbee;
5840     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5841     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5842     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5843     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5844
5845     state = 0xdeadbee;
5846     action = 0xdeadbee;
5847     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5848     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5849     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5850     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5851
5852     state = 0xdeadbee;
5853     action = 0xdeadbee;
5854     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5855     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5856     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5857     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5858
5859     state = 0xdeadbee;
5860     action = 0xdeadbee;
5861     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5862     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5863     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5864     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5865
5866     state = 0xdeadbee;
5867     action = 0xdeadbee;
5868     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5869     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5870     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5871     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5872
5873     state = 0xdeadbee;
5874     action = 0xdeadbee;
5875     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5876     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5877     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5878     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5879
5880     state = 0xdeadbee;
5881     action = 0xdeadbee;
5882     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5883     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5884     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5885     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5886
5887     state = 0xdeadbee;
5888     action = 0xdeadbee;
5889     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5890     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5891     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5892     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5893
5894     state = 0xdeadbee;
5895     action = 0xdeadbee;
5896     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5897     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5898     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5899     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5900
5901     state = 0xdeadbee;
5902     action = 0xdeadbee;
5903     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5904     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5905     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5906     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5907
5908     state = 0xdeadbee;
5909     action = 0xdeadbee;
5910     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5911     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5912     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5913     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5914
5915     state = 0xdeadbee;
5916     action = 0xdeadbee;
5917     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5918     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5919     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5920     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5921
5922     state = 0xdeadbee;
5923     action = 0xdeadbee;
5924     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5925     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5926     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5927     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5928
5929     state = 0xdeadbee;
5930     action = 0xdeadbee;
5931     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5932     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5933     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5934     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5935
5936     state = 0xdeadbee;
5937     action = 0xdeadbee;
5938     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5939     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5940     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5941     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5942
5943     state = 0xdeadbee;
5944     action = 0xdeadbee;
5945     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5946     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5947     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5948     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5949
5950     state = 0xdeadbee;
5951     action = 0xdeadbee;
5952     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5953     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5954     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5955     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5956
5957     state = 0xdeadbee;
5958     action = 0xdeadbee;
5959     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5960     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5961     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5962     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5963
5964     state = 0xdeadbee;
5965     action = 0xdeadbee;
5966     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5967     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5968     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5969     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5970
5971     state = 0xdeadbee;
5972     action = 0xdeadbee;
5973     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5974     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5975     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5976     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5977
5978     state = 0xdeadbee;
5979     action = 0xdeadbee;
5980     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5981     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5982     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5983     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5984
5985     state = 0xdeadbee;
5986     action = 0xdeadbee;
5987     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5988     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5989     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5990     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5991
5992     state = 0xdeadbee;
5993     action = 0xdeadbee;
5994     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5996     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5997     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5998
5999     state = 0xdeadbee;
6000     action = 0xdeadbee;
6001     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6002     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6003     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6004     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6005
6006     state = 0xdeadbee;
6007     action = 0xdeadbee;
6008     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6009     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6010     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6011     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6012
6013     state = 0xdeadbee;
6014     action = 0xdeadbee;
6015     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6017     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6018     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6019
6020     r = MsiDoAction( hpkg, "CostFinalize");
6021     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6022
6023     state = 0xdeadbee;
6024     action = 0xdeadbee;
6025     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6026     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6027     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6028     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6029
6030     state = 0xdeadbee;
6031     action = 0xdeadbee;
6032     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6034     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6035     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6036
6037     state = 0xdeadbee;
6038     action = 0xdeadbee;
6039     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6040     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6041     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6042     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6043
6044     state = 0xdeadbee;
6045     action = 0xdeadbee;
6046     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6047     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6048     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6049     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6050
6051     state = 0xdeadbee;
6052     action = 0xdeadbee;
6053     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6055     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6056     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6057
6058     state = 0xdeadbee;
6059     action = 0xdeadbee;
6060     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6061     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6062     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6063     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6064
6065     state = 0xdeadbee;
6066     action = 0xdeadbee;
6067     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6068     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6069     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6070     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6071
6072     state = 0xdeadbee;
6073     action = 0xdeadbee;
6074     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6075     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6076     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6077     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6078
6079     state = 0xdeadbee;
6080     action = 0xdeadbee;
6081     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6082     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6083     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6084     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6085
6086     state = 0xdeadbee;
6087     action = 0xdeadbee;
6088     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6089     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6090     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6091     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6092
6093     state = 0xdeadbee;
6094     action = 0xdeadbee;
6095     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6096     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6097     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6098     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6099
6100     state = 0xdeadbee;
6101     action = 0xdeadbee;
6102     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6103     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6104     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6105     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6106
6107     state = 0xdeadbee;
6108     action = 0xdeadbee;
6109     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6110     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6111     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6112     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6113
6114     state = 0xdeadbee;
6115     action = 0xdeadbee;
6116     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6118     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6119     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6120
6121     state = 0xdeadbee;
6122     action = 0xdeadbee;
6123     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6124     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6125     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6126     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6127
6128     state = 0xdeadbee;
6129     action = 0xdeadbee;
6130     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6131     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6132     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6133     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6134
6135     state = 0xdeadbee;
6136     action = 0xdeadbee;
6137     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6138     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6139     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6140     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6141
6142     state = 0xdeadbee;
6143     action = 0xdeadbee;
6144     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6146     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6147     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6148
6149     state = 0xdeadbee;
6150     action = 0xdeadbee;
6151     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6152     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6153     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6154     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6155
6156     state = 0xdeadbee;
6157     action = 0xdeadbee;
6158     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6160     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6161     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6162
6163     state = 0xdeadbee;
6164     action = 0xdeadbee;
6165     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6167     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6168     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6169
6170     state = 0xdeadbee;
6171     action = 0xdeadbee;
6172     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6174     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6175     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6176
6177     state = 0xdeadbee;
6178     action = 0xdeadbee;
6179     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6181     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6182     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6183
6184     state = 0xdeadbee;
6185     action = 0xdeadbee;
6186     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6188     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6189     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6190
6191     state = 0xdeadbee;
6192     action = 0xdeadbee;
6193     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6195     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6196     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6197
6198     state = 0xdeadbee;
6199     action = 0xdeadbee;
6200     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6202     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6203     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6204
6205     state = 0xdeadbee;
6206     action = 0xdeadbee;
6207     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6209     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6210     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6211
6212     state = 0xdeadbee;
6213     action = 0xdeadbee;
6214     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6216     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6217     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6218
6219     state = 0xdeadbee;
6220     action = 0xdeadbee;
6221     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6223     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6224     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6225
6226     state = 0xdeadbee;
6227     action = 0xdeadbee;
6228     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6230     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6231     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6232
6233     state = 0xdeadbee;
6234     action = 0xdeadbee;
6235     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6237     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6238     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6239
6240     MsiCloseHandle(hpkg);
6241
6242     /* reinstall the product */
6243     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6244     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6245
6246     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6247     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6248
6249     /* this property must not be in the saved msi file */
6250     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6251     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6252
6253     hpkg = package_from_db( hdb );
6254     ok( hpkg, "failed to create package\n");
6255
6256     state = 0xdeadbee;
6257     action = 0xdeadbee;
6258     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6259     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6260     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6261     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6262
6263     state = 0xdeadbee;
6264     action = 0xdeadbee;
6265     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6266     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6267     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6268     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6269
6270     state = 0xdeadbee;
6271     action = 0xdeadbee;
6272     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6273     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6274     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6275     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6276
6277     state = 0xdeadbee;
6278     action = 0xdeadbee;
6279     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6280     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6281     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6282     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6283
6284     state = 0xdeadbee;
6285     action = 0xdeadbee;
6286     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6287     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6288     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6289     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6290
6291     state = 0xdeadbee;
6292     action = 0xdeadbee;
6293     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6294     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6295     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6296     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6297
6298     state = 0xdeadbee;
6299     action = 0xdeadbee;
6300     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6301     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6302     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6303     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6304
6305     state = 0xdeadbee;
6306     action = 0xdeadbee;
6307     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6308     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6309     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6310     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6311
6312     state = 0xdeadbee;
6313     action = 0xdeadbee;
6314     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6315     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6316     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6317     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6318
6319     state = 0xdeadbee;
6320     action = 0xdeadbee;
6321     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6322     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6323     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6324     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6325
6326     state = 0xdeadbee;
6327     action = 0xdeadbee;
6328     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6329     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6330     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6331     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6332
6333     state = 0xdeadbee;
6334     action = 0xdeadbee;
6335     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6336     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6337     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6338     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6339
6340     state = 0xdeadbee;
6341     action = 0xdeadbee;
6342     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6343     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6344     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6345     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6346
6347     state = 0xdeadbee;
6348     action = 0xdeadbee;
6349     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6350     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6351     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6352     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6353
6354     state = 0xdeadbee;
6355     action = 0xdeadbee;
6356     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6357     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6358     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6359     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6360
6361     state = 0xdeadbee;
6362     action = 0xdeadbee;
6363     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6364     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6365     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6366     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6367
6368     state = 0xdeadbee;
6369     action = 0xdeadbee;
6370     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6371     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6372     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6373     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6374
6375     state = 0xdeadbee;
6376     action = 0xdeadbee;
6377     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6378     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6379     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6380     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6381
6382     state = 0xdeadbee;
6383     action = 0xdeadbee;
6384     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6385     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6386     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6387     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6388
6389     state = 0xdeadbee;
6390     action = 0xdeadbee;
6391     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6392     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6393     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6394     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6395
6396     state = 0xdeadbee;
6397     action = 0xdeadbee;
6398     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6399     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6400     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6401     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6402
6403     state = 0xdeadbee;
6404     action = 0xdeadbee;
6405     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6406     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6407     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6408     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6409
6410     state = 0xdeadbee;
6411     action = 0xdeadbee;
6412     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6413     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6414     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6415     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6416
6417     state = 0xdeadbee;
6418     action = 0xdeadbee;
6419     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6420     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6421     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6422     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6423
6424     state = 0xdeadbee;
6425     action = 0xdeadbee;
6426     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6427     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6428     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6429     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6430
6431     state = 0xdeadbee;
6432     action = 0xdeadbee;
6433     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6434     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6435     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6436     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6437
6438     state = 0xdeadbee;
6439     action = 0xdeadbee;
6440     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6441     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6442     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6443     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6444
6445     state = 0xdeadbee;
6446     action = 0xdeadbee;
6447     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6448     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6449     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6450     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6451
6452     state = 0xdeadbee;
6453     action = 0xdeadbee;
6454     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6455     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6456     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6457     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6458
6459     state = 0xdeadbee;
6460     action = 0xdeadbee;
6461     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6462     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6463     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6464     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6465
6466     state = 0xdeadbee;
6467     action = 0xdeadbee;
6468     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6469     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6470     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6471     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6472
6473     r = MsiDoAction( hpkg, "CostInitialize");
6474     ok( r == ERROR_SUCCESS, "cost init failed\n");
6475
6476     state = 0xdeadbee;
6477     action = 0xdeadbee;
6478     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6479     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6480     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6481     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6482
6483     state = 0xdeadbee;
6484     action = 0xdeadbee;
6485     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6486     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6487     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6488     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6489
6490     state = 0xdeadbee;
6491     action = 0xdeadbee;
6492     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6493     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6494     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6495     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6496
6497     state = 0xdeadbee;
6498     action = 0xdeadbee;
6499     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6500     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6501     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6502     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6503
6504     state = 0xdeadbee;
6505     action = 0xdeadbee;
6506     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6507     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6508     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6509     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6510
6511     state = 0xdeadbee;
6512     action = 0xdeadbee;
6513     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6514     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6515     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6516     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6517
6518     state = 0xdeadbee;
6519     action = 0xdeadbee;
6520     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6521     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6522     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6523     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6524
6525     state = 0xdeadbee;
6526     action = 0xdeadbee;
6527     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6528     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6529     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6530     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6531
6532     state = 0xdeadbee;
6533     action = 0xdeadbee;
6534     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6535     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6536     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6537     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6538
6539     state = 0xdeadbee;
6540     action = 0xdeadbee;
6541     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6542     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6543     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6544     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6545
6546     state = 0xdeadbee;
6547     action = 0xdeadbee;
6548     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6549     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6550     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6551     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6552
6553     state = 0xdeadbee;
6554     action = 0xdeadbee;
6555     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6556     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6557     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6558     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6559
6560     state = 0xdeadbee;
6561     action = 0xdeadbee;
6562     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6563     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6564     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6565     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6566
6567     state = 0xdeadbee;
6568     action = 0xdeadbee;
6569     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6570     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6571     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6572     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6573
6574     state = 0xdeadbee;
6575     action = 0xdeadbee;
6576     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6577     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6578     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6579     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6580
6581     state = 0xdeadbee;
6582     action = 0xdeadbee;
6583     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6584     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6585     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6586     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6587
6588     state = 0xdeadbee;
6589     action = 0xdeadbee;
6590     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6591     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6592     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6593     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6594
6595     state = 0xdeadbee;
6596     action = 0xdeadbee;
6597     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6598     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6599     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6600     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6601
6602     state = 0xdeadbee;
6603     action = 0xdeadbee;
6604     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6605     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6606     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6607     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6608
6609     state = 0xdeadbee;
6610     action = 0xdeadbee;
6611     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6612     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6613     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6614     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6615
6616     state = 0xdeadbee;
6617     action = 0xdeadbee;
6618     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6619     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6620     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6621     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6622
6623     state = 0xdeadbee;
6624     action = 0xdeadbee;
6625     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6626     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6627     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6628     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6629
6630     state = 0xdeadbee;
6631     action = 0xdeadbee;
6632     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6633     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6634     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6635     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6636
6637     state = 0xdeadbee;
6638     action = 0xdeadbee;
6639     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6640     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6641     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6642     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6643
6644     state = 0xdeadbee;
6645     action = 0xdeadbee;
6646     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6647     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6648     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6649     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6650
6651     state = 0xdeadbee;
6652     action = 0xdeadbee;
6653     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6654     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6655     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6656     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6657
6658     state = 0xdeadbee;
6659     action = 0xdeadbee;
6660     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6661     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6662     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6663     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6664
6665     state = 0xdeadbee;
6666     action = 0xdeadbee;
6667     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6668     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6669     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6670     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6671
6672     state = 0xdeadbee;
6673     action = 0xdeadbee;
6674     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6675     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6676     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6677     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6678
6679     state = 0xdeadbee;
6680     action = 0xdeadbee;
6681     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6682     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6683     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6684     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6685
6686     state = 0xdeadbee;
6687     action = 0xdeadbee;
6688     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6689     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6690     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6691     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6692
6693     r = MsiDoAction( hpkg, "FileCost");
6694     ok( r == ERROR_SUCCESS, "file cost failed\n");
6695
6696     state = 0xdeadbee;
6697     action = 0xdeadbee;
6698     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6699     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6700     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6701     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6702
6703     state = 0xdeadbee;
6704     action = 0xdeadbee;
6705     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6706     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6707     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6708     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6709
6710     state = 0xdeadbee;
6711     action = 0xdeadbee;
6712     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6713     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6714     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6715     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6716
6717     state = 0xdeadbee;
6718     action = 0xdeadbee;
6719     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6720     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6721     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6722     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6723
6724     state = 0xdeadbee;
6725     action = 0xdeadbee;
6726     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6727     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6728     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6729     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6730
6731     state = 0xdeadbee;
6732     action = 0xdeadbee;
6733     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6734     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6735     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6736     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6737
6738     state = 0xdeadbee;
6739     action = 0xdeadbee;
6740     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6741     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6742     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6743     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6744
6745     state = 0xdeadbee;
6746     action = 0xdeadbee;
6747     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6748     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6749     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6750     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6751
6752     state = 0xdeadbee;
6753     action = 0xdeadbee;
6754     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6755     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6756     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6757     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6758
6759     state = 0xdeadbee;
6760     action = 0xdeadbee;
6761     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6762     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6763     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6764     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6765
6766     state = 0xdeadbee;
6767     action = 0xdeadbee;
6768     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6769     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6770     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6771     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6772
6773     state = 0xdeadbee;
6774     action = 0xdeadbee;
6775     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6776     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6777     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6778     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6779
6780     state = 0xdeadbee;
6781     action = 0xdeadbee;
6782     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6783     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6784     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6785     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6786
6787     state = 0xdeadbee;
6788     action = 0xdeadbee;
6789     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6790     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6791     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6792     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6793
6794     state = 0xdeadbee;
6795     action = 0xdeadbee;
6796     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6797     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6798     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6799     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6800
6801     state = 0xdeadbee;
6802     action = 0xdeadbee;
6803     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6804     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6805     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6806     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6807
6808     state = 0xdeadbee;
6809     action = 0xdeadbee;
6810     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6811     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6812     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6813     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6814
6815     state = 0xdeadbee;
6816     action = 0xdeadbee;
6817     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6818     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6819     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6820     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6821
6822     state = 0xdeadbee;
6823     action = 0xdeadbee;
6824     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6825     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6826     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6827     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6828
6829     state = 0xdeadbee;
6830     action = 0xdeadbee;
6831     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6832     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6833     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6834     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6835
6836     state = 0xdeadbee;
6837     action = 0xdeadbee;
6838     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6839     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6840     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6841     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6842
6843     state = 0xdeadbee;
6844     action = 0xdeadbee;
6845     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6846     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6847     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6848     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6849
6850     state = 0xdeadbee;
6851     action = 0xdeadbee;
6852     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6853     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6854     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6855     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6856
6857     state = 0xdeadbee;
6858     action = 0xdeadbee;
6859     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6860     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6861     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6862     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6863
6864     state = 0xdeadbee;
6865     action = 0xdeadbee;
6866     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6867     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6868     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6869     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6870
6871     state = 0xdeadbee;
6872     action = 0xdeadbee;
6873     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6874     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6875     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6876     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6877
6878     state = 0xdeadbee;
6879     action = 0xdeadbee;
6880     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6881     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6882     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6883     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6884
6885     state = 0xdeadbee;
6886     action = 0xdeadbee;
6887     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6888     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6889     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6890     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6891
6892     state = 0xdeadbee;
6893     action = 0xdeadbee;
6894     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6895     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6896     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6897     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6898
6899     state = 0xdeadbee;
6900     action = 0xdeadbee;
6901     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6902     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6903     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6904     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6905
6906     state = 0xdeadbee;
6907     action = 0xdeadbee;
6908     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6909     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6910     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6911     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6912
6913     r = MsiDoAction( hpkg, "CostFinalize");
6914     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6915
6916     state = 0xdeadbee;
6917     action = 0xdeadbee;
6918     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6919     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6920     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6921     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6922
6923     state = 0xdeadbee;
6924     action = 0xdeadbee;
6925     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6926     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6927     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6928     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6929
6930     state = 0xdeadbee;
6931     action = 0xdeadbee;
6932     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6933     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6934     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6935     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6936
6937     state = 0xdeadbee;
6938     action = 0xdeadbee;
6939     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6940     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6941     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6942     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6943
6944     state = 0xdeadbee;
6945     action = 0xdeadbee;
6946     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6947     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6948     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6949     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6950
6951     state = 0xdeadbee;
6952     action = 0xdeadbee;
6953     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6954     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6955     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6956     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6957
6958     state = 0xdeadbee;
6959     action = 0xdeadbee;
6960     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6961     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6962     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6963     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6964
6965     state = 0xdeadbee;
6966     action = 0xdeadbee;
6967     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6968     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6969     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6970     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6971
6972     state = 0xdeadbee;
6973     action = 0xdeadbee;
6974     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6975     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6976     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6977     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6978
6979     state = 0xdeadbee;
6980     action = 0xdeadbee;
6981     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6982     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6983     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6984     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6985
6986     state = 0xdeadbee;
6987     action = 0xdeadbee;
6988     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6989     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6990     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6991     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6992
6993     state = 0xdeadbee;
6994     action = 0xdeadbee;
6995     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6996     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6997     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6998     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6999
7000     state = 0xdeadbee;
7001     action = 0xdeadbee;
7002     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7003     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7004     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7005     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7006
7007     state = 0xdeadbee;
7008     action = 0xdeadbee;
7009     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7010     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7011     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7012     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7013
7014     state = 0xdeadbee;
7015     action = 0xdeadbee;
7016     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7017     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7018     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7019     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7020
7021     state = 0xdeadbee;
7022     action = 0xdeadbee;
7023     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7024     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7025     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7026     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7027
7028     state = 0xdeadbee;
7029     action = 0xdeadbee;
7030     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7031     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7032     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7033     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7034
7035     state = 0xdeadbee;
7036     action = 0xdeadbee;
7037     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7038     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7039     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7040     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7041
7042     state = 0xdeadbee;
7043     action = 0xdeadbee;
7044     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7045     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7046     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7047     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7048
7049     state = 0xdeadbee;
7050     action = 0xdeadbee;
7051     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7052     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7053     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7054     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7055
7056     state = 0xdeadbee;
7057     action = 0xdeadbee;
7058     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7059     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7060     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7061     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7062
7063     state = 0xdeadbee;
7064     action = 0xdeadbee;
7065     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7066     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7067     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7068     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7069
7070     state = 0xdeadbee;
7071     action = 0xdeadbee;
7072     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7073     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7074     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7075     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7076
7077     state = 0xdeadbee;
7078     action = 0xdeadbee;
7079     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7080     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7081     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7082     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7083
7084     state = 0xdeadbee;
7085     action = 0xdeadbee;
7086     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7087     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7088     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7089     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7090
7091     state = 0xdeadbee;
7092     action = 0xdeadbee;
7093     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7094     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7095     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7096     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7097
7098     state = 0xdeadbee;
7099     action = 0xdeadbee;
7100     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7101     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7102     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7103     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7104
7105     state = 0xdeadbee;
7106     action = 0xdeadbee;
7107     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7108     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7109     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7110     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7111
7112     state = 0xdeadbee;
7113     action = 0xdeadbee;
7114     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7115     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7116     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7117     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7118
7119     state = 0xdeadbee;
7120     action = 0xdeadbee;
7121     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7122     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7123     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7124     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7125
7126     state = 0xdeadbee;
7127     action = 0xdeadbee;
7128     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7129     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7130     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7131     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7132
7133     MsiCloseHandle(hpkg);
7134
7135     /* uninstall the product */
7136     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7138
7139     DeleteFileA(msifile);
7140     DeleteFileA(msifile2);
7141     DeleteFileA(msifile3);
7142     DeleteFileA(msifile4);
7143 }
7144
7145 static void test_getproperty(void)
7146 {
7147     MSIHANDLE hPackage = 0;
7148     char prop[100];
7149     static CHAR empty[] = "";
7150     DWORD size;
7151     UINT r;
7152
7153     hPackage = package_from_db(create_package_db());
7154     ok( hPackage != 0, " Failed to create package\n");
7155
7156     /* set the property */
7157     r = MsiSetProperty(hPackage, "Name", "Value");
7158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7159
7160     /* retrieve the size, NULL pointer */
7161     size = 0;
7162     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7164     ok( size == 5, "Expected 5, got %d\n", size);
7165
7166     /* retrieve the size, empty string */
7167     size = 0;
7168     r = MsiGetProperty(hPackage, "Name", empty, &size);
7169     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7170     ok( size == 5, "Expected 5, got %d\n", size);
7171
7172     /* don't change size */
7173     r = MsiGetProperty(hPackage, "Name", prop, &size);
7174     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7175     ok( size == 5, "Expected 5, got %d\n", size);
7176     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7177
7178     /* increase the size by 1 */
7179     size++;
7180     r = MsiGetProperty(hPackage, "Name", prop, &size);
7181     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7182     ok( size == 5, "Expected 5, got %d\n", size);
7183     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7184
7185     r = MsiCloseHandle( hPackage);
7186     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7187     DeleteFile(msifile);
7188 }
7189
7190 static void test_removefiles(void)
7191 {
7192     MSIHANDLE hpkg;
7193     UINT r;
7194     MSIHANDLE hdb;
7195
7196     hdb = create_package_db();
7197     ok ( hdb, "failed to create package database\n" );
7198
7199     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7200     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7201
7202     r = create_feature_table( hdb );
7203     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7204
7205     r = create_component_table( hdb );
7206     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7207
7208     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7209     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7210
7211     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7212     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7213
7214     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7215     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7216
7217     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7218     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7219
7220     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7221     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7222
7223     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7224     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7225
7226     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7227     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7228
7229     r = create_feature_components_table( hdb );
7230     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7231
7232     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7233     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7234
7235     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7236     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7237
7238     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7239     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7240
7241     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7242     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7243
7244     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7245     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7246
7247     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7248     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7249
7250     r = create_file_table( hdb );
7251     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7252
7253     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7254     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7255
7256     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7257     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7258
7259     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7260     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7261
7262     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7263     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7264
7265     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7266     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7267
7268     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7269     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7270
7271     r = create_remove_file_table( hdb );
7272     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7273
7274     hpkg = package_from_db( hdb );
7275     ok( hpkg, "failed to create package\n");
7276
7277     MsiCloseHandle( hdb );
7278
7279     create_test_file( "hydrogen.txt" );
7280     create_test_file( "helium.txt" );
7281     create_test_file( "lithium.txt" );
7282     create_test_file( "beryllium.txt" );
7283     create_test_file( "boron.txt" );
7284     create_test_file( "carbon.txt" );
7285
7286     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7287     ok( r == ERROR_SUCCESS, "set property failed\n");
7288
7289     r = MsiDoAction( hpkg, "CostInitialize");
7290     ok( r == ERROR_SUCCESS, "cost init failed\n");
7291
7292     r = MsiDoAction( hpkg, "FileCost");
7293     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7294
7295     r = MsiDoAction( hpkg, "CostFinalize");
7296     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7297
7298     r = MsiDoAction( hpkg, "InstallValidate");
7299     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7300
7301     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7302     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7303
7304     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7305     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7306
7307     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7308     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7309
7310     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7311     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7312
7313     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7314     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7315
7316     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7317     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7318
7319     r = MsiDoAction( hpkg, "RemoveFiles");
7320     ok( r == ERROR_SUCCESS, "remove files failed\n");
7321
7322     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7323     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7324     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7325     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7326     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7327     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7328
7329     MsiCloseHandle( hpkg );
7330     DeleteFileA(msifile);
7331 }
7332
7333 static void test_appsearch(void)
7334 {
7335     MSIHANDLE hpkg;
7336     UINT r;
7337     MSIHANDLE hdb;
7338     CHAR prop[MAX_PATH];
7339     DWORD size = MAX_PATH;
7340
7341     hdb = create_package_db();
7342     ok ( hdb, "failed to create package database\n" );
7343
7344     r = create_appsearch_table( hdb );
7345     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7346
7347     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7348     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7349
7350     r = create_reglocator_table( hdb );
7351     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7352
7353     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
7354     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7355
7356     r = create_signature_table( hdb );
7357     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7358
7359     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7360     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7361
7362     hpkg = package_from_db( hdb );
7363     ok( hpkg, "failed to create package\n");
7364
7365     MsiCloseHandle( hdb );
7366
7367     r = MsiDoAction( hpkg, "AppSearch" );
7368     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7369
7370     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7371     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7372     todo_wine
7373     {
7374         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7375     }
7376
7377     MsiCloseHandle( hpkg );
7378     DeleteFileA(msifile);
7379 }
7380
7381 static void test_appsearch_complocator(void)
7382 {
7383     MSIHANDLE hpkg, hdb;
7384     CHAR path[MAX_PATH];
7385     CHAR prop[MAX_PATH];
7386     LPSTR usersid;
7387     DWORD size;
7388     UINT r;
7389
7390     if (!get_user_sid(&usersid))
7391         return;
7392
7393     create_test_file("FileName1");
7394     create_test_file("FileName4");
7395     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
7396                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
7397
7398     create_test_file("FileName2");
7399     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
7400                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
7401
7402     create_test_file("FileName3");
7403     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
7404                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
7405
7406     create_test_file("FileName5");
7407     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
7408                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
7409
7410     create_test_file("FileName6");
7411     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
7412                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
7413
7414     create_test_file("FileName7");
7415     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
7416                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
7417
7418     /* dir is FALSE, but we're pretending it's a directory */
7419     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
7420                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
7421
7422     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7423     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
7424                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
7425
7426     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7427     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
7428                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
7429
7430     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7431     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
7432                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
7433
7434     hdb = create_package_db();
7435     ok(hdb, "Expected a valid database handle\n");
7436
7437     r = create_appsearch_table(hdb);
7438     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7439
7440     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7441     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7442
7443     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
7444     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7445
7446     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
7447     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7448
7449     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
7450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7451
7452     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
7453     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7454
7455     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
7456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7457
7458     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
7459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7460
7461     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
7462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7463
7464     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
7465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7466
7467     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
7468     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7469
7470     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
7471     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7472
7473     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
7474     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7475
7476     r = create_complocator_table(hdb);
7477     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7478
7479     /* published component, machine, file, signature, misdbLocatorTypeFile */
7480     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
7481     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7482
7483     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
7484     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
7485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7486
7487     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
7488     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
7489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7490
7491     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
7492     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
7493     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7494
7495     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
7496     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
7497     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7498
7499     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
7500     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
7501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7502
7503     /* published component, machine, file, no signature, misdbLocatorTypeFile */
7504     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
7505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7506
7507     /* unpublished component, no signature, misdbLocatorTypeDir */
7508     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
7509     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7510
7511     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
7512     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
7513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7514
7515     /* published component, signature w/ ver, misdbLocatorTypeFile */
7516     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
7517     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7518
7519     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
7520     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
7521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7522
7523     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
7524     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
7525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7526
7527     r = create_signature_table(hdb);
7528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7529
7530     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
7531     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7532
7533     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
7534     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7535
7536     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
7537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7538
7539     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
7540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7541
7542     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
7543     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7544
7545     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7546     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7547
7548     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7549     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7550
7551     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7552     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7553
7554     hpkg = package_from_db(hdb);
7555     ok(hpkg, "Expected a valid package handle\n");
7556
7557     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
7558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7559
7560     r = MsiDoAction(hpkg, "AppSearch");
7561     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7562
7563     size = MAX_PATH;
7564     sprintf(path, "%s\\FileName1", CURR_DIR);
7565     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
7566     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7567     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7568
7569     size = MAX_PATH;
7570     sprintf(path, "%s\\FileName2", CURR_DIR);
7571     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
7572     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7573     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7574
7575     size = MAX_PATH;
7576     sprintf(path, "%s\\FileName3", CURR_DIR);
7577     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
7578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7579     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7580
7581     size = MAX_PATH;
7582     sprintf(path, "%s\\FileName4", CURR_DIR);
7583     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
7584     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7585     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7586
7587     size = MAX_PATH;
7588     sprintf(path, "%s\\FileName5", CURR_DIR);
7589     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
7590     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7591     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7592
7593     size = MAX_PATH;
7594     sprintf(path, "%s\\", CURR_DIR);
7595     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
7596     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7597     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7598
7599     size = MAX_PATH;
7600     sprintf(path, "%s\\", CURR_DIR);
7601     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
7602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7603     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7604
7605     size = MAX_PATH;
7606     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
7607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7608     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
7609
7610     size = MAX_PATH;
7611     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
7612     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7613     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7614
7615     size = MAX_PATH;
7616     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
7617     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
7618     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7619     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7620
7621     size = MAX_PATH;
7622     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
7623     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7624     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7625
7626     size = MAX_PATH;
7627     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
7628     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
7629     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7630     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7631
7632     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
7633                           MSIINSTALLCONTEXT_MACHINE, NULL);
7634     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
7635                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
7636     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
7637                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
7638     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
7639                           MSIINSTALLCONTEXT_MACHINE, NULL);
7640     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
7641                           MSIINSTALLCONTEXT_MACHINE, NULL);
7642     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
7643                           MSIINSTALLCONTEXT_MACHINE, NULL);
7644     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
7645                           MSIINSTALLCONTEXT_MACHINE, NULL);
7646     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
7647                           MSIINSTALLCONTEXT_MACHINE, NULL);
7648     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
7649                           MSIINSTALLCONTEXT_MACHINE, NULL);
7650     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
7651                           MSIINSTALLCONTEXT_MACHINE, NULL);
7652
7653     DeleteFileA("FileName1");
7654     DeleteFileA("FileName2");
7655     DeleteFileA("FileName3");
7656     DeleteFileA("FileName4");
7657     DeleteFileA("FileName5");
7658     DeleteFileA("FileName6");
7659     DeleteFileA("FileName7");
7660     DeleteFileA("FileName8.dll");
7661     DeleteFileA("FileName9.dll");
7662     DeleteFileA("FileName10.dll");
7663     MsiCloseHandle(hpkg);
7664     DeleteFileA(msifile);
7665 }
7666
7667 static void test_appsearch_reglocator(void)
7668 {
7669     MSIHANDLE hpkg, hdb;
7670     CHAR path[MAX_PATH];
7671     CHAR prop[MAX_PATH];
7672     DWORD binary[2];
7673     DWORD size, val;
7674     BOOL space, version;
7675     HKEY hklm, classes;
7676     HKEY hkcu, users;
7677     LPSTR pathdata;
7678     LPSTR pathvar;
7679     LPCSTR str;
7680     LPSTR ptr;
7681     LONG res;
7682     UINT r;
7683
7684     version = TRUE;
7685     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
7686         version = FALSE;
7687
7688     DeleteFileA("test.dll");
7689
7690     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
7691     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7692
7693     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
7694                          (const BYTE *)"regszdata", 10);
7695     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7696
7697     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
7698     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7699
7700     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
7701                          (const BYTE *)"regszdata", 10);
7702     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7703
7704     users = 0;
7705     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
7706     ok(res == ERROR_SUCCESS ||
7707        broken(res == ERROR_INVALID_PARAMETER),
7708        "Expected ERROR_SUCCESS, got %d\n", res);
7709
7710     if (res == ERROR_SUCCESS)
7711     {
7712         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
7713                              (const BYTE *)"regszdata", 10);
7714         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7715     }
7716
7717     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
7718     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7719
7720     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
7721     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7722
7723     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
7724                          (const BYTE *)"regszdata", 10);
7725     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7726
7727     val = 42;
7728     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
7729                          (const BYTE *)&val, sizeof(DWORD));
7730     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7731
7732     val = -42;
7733     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
7734                          (const BYTE *)&val, sizeof(DWORD));
7735     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7736
7737     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
7738                          (const BYTE *)"%PATH%", 7);
7739     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7740
7741     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
7742                          (const BYTE *)"my%NOVAR%", 10);
7743     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7744
7745     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
7746                          (const BYTE *)"one\0two\0", 9);
7747     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7748
7749     binary[0] = 0x1234abcd;
7750     binary[1] = 0x567890ef;
7751     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
7752                          (const BYTE *)binary, sizeof(binary));
7753     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7754
7755     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
7756                          (const BYTE *)"#regszdata", 11);
7757     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7758
7759     create_test_file("FileName1");
7760     sprintf(path, "%s\\FileName1", CURR_DIR);
7761     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
7762                          (const BYTE *)path, lstrlenA(path) + 1);
7763     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7764
7765     sprintf(path, "%s\\FileName2", CURR_DIR);
7766     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
7767                          (const BYTE *)path, lstrlenA(path) + 1);
7768     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7769
7770     lstrcpyA(path, CURR_DIR);
7771     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
7772                          (const BYTE *)path, lstrlenA(path) + 1);
7773     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7774
7775     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
7776                          (const BYTE *)"", 1);
7777     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7778
7779     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7780     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
7781     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
7782                          (const BYTE *)path, lstrlenA(path) + 1);
7783     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7784
7785     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7786     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
7787     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
7788                          (const BYTE *)path, lstrlenA(path) + 1);
7789     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7790
7791     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7792     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
7793     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
7794                          (const BYTE *)path, lstrlenA(path) + 1);
7795     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7796
7797     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
7798     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
7799                          (const BYTE *)path, lstrlenA(path) + 1);
7800
7801     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
7802     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
7803     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
7804                          (const BYTE *)path, lstrlenA(path) + 1);
7805
7806     hdb = create_package_db();
7807     ok(hdb, "Expected a valid database handle\n");
7808
7809     r = create_appsearch_table(hdb);
7810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7811
7812     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7813     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7814
7815     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
7816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7817
7818     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
7819     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7820
7821     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
7822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7823
7824     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
7825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7826
7827     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
7828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7829
7830     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
7831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7832
7833     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
7834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7835
7836     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
7837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7838
7839     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
7840     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7841
7842     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
7843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7844
7845     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
7846     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7847
7848     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
7849     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7850
7851     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
7852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7853
7854     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
7855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7856
7857     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
7858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7859
7860     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
7861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7862
7863     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
7864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7865
7866     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
7867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7868
7869     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
7870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7871
7872     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
7873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7874
7875     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
7876     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7877
7878     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
7879     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7880
7881     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
7882     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7883
7884     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
7885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7886
7887     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
7888     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7889
7890     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
7891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7892
7893     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
7894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7895
7896     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
7897     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7898
7899     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
7900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7901
7902     r = create_reglocator_table(hdb);
7903     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7904
7905     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
7906     str = "'NewSignature1', 2, 'Software\\Wine', 'Value1', 2";
7907     r = add_reglocator_entry(hdb, str);
7908     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7909
7910     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
7911     str = "'NewSignature2', 2, 'Software\\Wine', 'Value2', 2";
7912     r = add_reglocator_entry(hdb, str);
7913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7914
7915     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
7916     str = "'NewSignature3', 2, 'Software\\Wine', 'Value3', 2";
7917     r = add_reglocator_entry(hdb, str);
7918     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7919
7920     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
7921     str = "'NewSignature4', 2, 'Software\\Wine', 'Value4', 2";
7922     r = add_reglocator_entry(hdb, str);
7923     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7924
7925     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
7926     str = "'NewSignature5', 2, 'Software\\Wine', 'Value5', 2";
7927     r = add_reglocator_entry(hdb, str);
7928     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7929
7930     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
7931     str = "'NewSignature6', 2, 'Software\\Wine', 'Value6', 2";
7932     r = add_reglocator_entry(hdb, str);
7933     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7934
7935     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
7936     str = "'NewSignature7', 2, 'Software\\Wine', 'Value7', 2";
7937     r = add_reglocator_entry(hdb, str);
7938     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7939
7940     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
7941     str = "'NewSignature8', 2, 'Software\\Wine', 'Value8', 2";
7942     r = add_reglocator_entry(hdb, str);
7943     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7944
7945     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
7946     str = "'NewSignature9', 2, 'Software\\Wine', 'Value9', 1";
7947     r = add_reglocator_entry(hdb, str);
7948     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7949
7950     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
7951     str = "'NewSignature10', 2, 'Software\\Wine', 'Value10', 1";
7952     r = add_reglocator_entry(hdb, str);
7953     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7954
7955     /* HKLM, msidbLocatorTypeFileName, no signature */
7956     str = "'NewSignature11', 2, 'Software\\Wine', 'Value9', 1";
7957     r = add_reglocator_entry(hdb, str);
7958     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7959
7960     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
7961     str = "'NewSignature12', 2, 'Software\\Wine', 'Value9', 0";
7962     r = add_reglocator_entry(hdb, str);
7963     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7964
7965     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
7966     str = "'NewSignature13', 2, 'Software\\Wine', 'Value11', 0";
7967     r = add_reglocator_entry(hdb, str);
7968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7969
7970     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
7971     str = "'NewSignature14', 2, 'Software\\Wine', 'Value9', 0";
7972     r = add_reglocator_entry(hdb, str);
7973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7974
7975     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
7976     str = "'NewSignature15', 0, 'Software\\Wine', 'Value1', 2";
7977     r = add_reglocator_entry(hdb, str);
7978     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7979
7980     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
7981     str = "'NewSignature16', 1, 'Software\\Wine', 'Value1', 2";
7982     r = add_reglocator_entry(hdb, str);
7983     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7984
7985     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
7986     str = "'NewSignature17', 3, 'S-1-5-18\\Software\\Wine', 'Value1', 2";
7987     r = add_reglocator_entry(hdb, str);
7988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7989
7990     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
7991     str = "'NewSignature18', 2, 'Software\\Wine', '', 2";
7992     r = add_reglocator_entry(hdb, str);
7993     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7994
7995     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
7996     str = "'NewSignature19', 2, 'Software\\IDontExist', '', 2";
7997     r = add_reglocator_entry(hdb, str);
7998     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7999
8000     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
8001     str = "'NewSignature20', 2, 'Software\\Wine', 'Value12', 2";
8002     r = add_reglocator_entry(hdb, str);
8003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8004
8005     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
8006     str = "'NewSignature21', 2, 'Software\\Wine', 'Value13', 1";
8007     r = add_reglocator_entry(hdb, str);
8008     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8009
8010     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
8011     str = "'NewSignature22', 2, 'Software\\Wine', 'Value14', 1";
8012     r = add_reglocator_entry(hdb, str);
8013     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8014
8015     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
8016     str = "'NewSignature23', 2, 'Software\\Wine', 'Value15', 1";
8017     r = add_reglocator_entry(hdb, str);
8018     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8019
8020     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
8021     str = "'NewSignature24', 2, 'Software\\Wine', 'Value11', 1";
8022     r = add_reglocator_entry(hdb, str);
8023     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8024
8025     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
8026     str = "'NewSignature25', 2, 'Software\\Wine', 'Value10', 1";
8027     r = add_reglocator_entry(hdb, str);
8028     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8029
8030     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8031     str = "'NewSignature26', 2, 'Software\\Wine', 'Value11', 0";
8032     r = add_reglocator_entry(hdb, str);
8033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8034
8035     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8036     str = "'NewSignature27', 2, 'Software\\Wine', 'Value10', 0";
8037     r = add_reglocator_entry(hdb, str);
8038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8039
8040     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8041     str = "'NewSignature28', 2, 'Software\\Wine', 'Value10', 0";
8042     r = add_reglocator_entry(hdb, str);
8043     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8044
8045     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8046     str = "'NewSignature29', 2, 'Software\\Wine', 'Value16', 1";
8047     r = add_reglocator_entry(hdb, str);
8048     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8049
8050     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8051     str = "'NewSignature30', 2, 'Software\\Wine', 'Value17', 1";
8052     r = add_reglocator_entry(hdb, str);
8053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8054
8055     r = create_signature_table(hdb);
8056     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8057
8058     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8059     r = add_signature_entry(hdb, str);
8060     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8061
8062     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8063     r = add_signature_entry(hdb, str);
8064     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8065
8066     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8067     r = add_signature_entry(hdb, str);
8068     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8069
8070     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8071     r = add_signature_entry(hdb, str);
8072     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8073
8074     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8075     r = add_signature_entry(hdb, str);
8076     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8077
8078     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8079     r = add_signature_entry(hdb, str);
8080     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8081
8082     ptr = strrchr(CURR_DIR, '\\') + 1;
8083     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8084     r = add_signature_entry(hdb, path);
8085     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8086
8087     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8088     r = add_signature_entry(hdb, str);
8089     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8090
8091     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8092     r = add_signature_entry(hdb, str);
8093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8094
8095     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8096     r = add_signature_entry(hdb, str);
8097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8098
8099     hpkg = package_from_db(hdb);
8100     ok(hpkg, "Expected a valid package handle\n");
8101
8102     r = MsiDoAction(hpkg, "AppSearch");
8103     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8104
8105     size = MAX_PATH;
8106     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8108     ok(!lstrcmpA(prop, "regszdata"),
8109        "Expected \"regszdata\", got \"%s\"\n", prop);
8110
8111     size = MAX_PATH;
8112     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8113     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8114     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8115
8116     size = MAX_PATH;
8117     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8118     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8119     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8120
8121     size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8122     if (size == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
8123     {
8124         /* Workaround for Win95 */
8125         CHAR tempbuf[1];
8126         size = ExpandEnvironmentStringsA("%PATH%", tempbuf, 0);
8127     }
8128     pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8129     ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8130
8131     size = 0;
8132     r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8134
8135     pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8136     r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8138     ok(!lstrcmpA(pathdata, pathvar),
8139        "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8140
8141     HeapFree(GetProcessHeap(), 0, pathvar);
8142     HeapFree(GetProcessHeap(), 0, pathdata);
8143
8144     size = MAX_PATH;
8145     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8146     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8147     ok(!lstrcmpA(prop,
8148        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8149
8150     size = MAX_PATH;
8151     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8152     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8153     todo_wine
8154     {
8155         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8156            "Expected \"\\0one\\0two\\0\\0\"\n");
8157     }
8158
8159     size = MAX_PATH;
8160     lstrcpyA(path, "#xCDAB3412EF907856");
8161     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8162     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8163     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8164
8165     size = MAX_PATH;
8166     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8167     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8168     ok(!lstrcmpA(prop, "##regszdata"),
8169        "Expected \"##regszdata\", got \"%s\"\n", prop);
8170
8171     size = MAX_PATH;
8172     sprintf(path, "%s\\FileName1", CURR_DIR);
8173     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8174     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8175     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8176
8177     size = MAX_PATH;
8178     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8179     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8180     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8181
8182     size = MAX_PATH;
8183     sprintf(path, "%s\\", CURR_DIR);
8184     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8185     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8186     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8187
8188     size = MAX_PATH;
8189     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8190     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8191     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8192
8193     size = MAX_PATH;
8194     sprintf(path, "%s\\", CURR_DIR);
8195     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
8196     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8197     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8198
8199     size = MAX_PATH;
8200     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
8201     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8202     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8203
8204     size = MAX_PATH;
8205     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8206     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8207     ok(!lstrcmpA(prop, "regszdata"),
8208        "Expected \"regszdata\", got \"%s\"\n", prop);
8209
8210     size = MAX_PATH;
8211     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8212     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8213     ok(!lstrcmpA(prop, "regszdata"),
8214        "Expected \"regszdata\", got \"%s\"\n", prop);
8215
8216     if (users)
8217     {
8218         size = MAX_PATH;
8219         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8220         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8221         ok(!lstrcmpA(prop, "regszdata"),
8222            "Expected \"regszdata\", got \"%s\"\n", prop);
8223     }
8224
8225     size = MAX_PATH;
8226     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8227     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8228     ok(!lstrcmpA(prop, "defvalue"),
8229        "Expected \"defvalue\", got \"%s\"\n", prop);
8230
8231     size = MAX_PATH;
8232     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8233     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8234     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8235
8236     size = MAX_PATH;
8237     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
8238     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8239     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8240
8241     if (version)
8242     {
8243         size = MAX_PATH;
8244         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8245         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8246         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8247         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8248
8249         size = MAX_PATH;
8250         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8251         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8252         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8253
8254         size = MAX_PATH;
8255         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8256         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8257         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8258         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8259     }
8260
8261     size = MAX_PATH;
8262     lstrcpyA(path, CURR_DIR);
8263     ptr = strrchr(path, '\\') + 1;
8264     *ptr = '\0';
8265     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8266     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8267     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8268
8269     size = MAX_PATH;
8270     sprintf(path, "%s\\", CURR_DIR);
8271     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8272     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8273     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8274
8275     size = MAX_PATH;
8276     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8277     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8278     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8279
8280     size = MAX_PATH;
8281     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8282     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8283     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8284
8285     size = MAX_PATH;
8286     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8288     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8289
8290     size = MAX_PATH;
8291     sprintf(path, "%s\\FileName1", CURR_DIR);
8292     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8293     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8294     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8295
8296     size = MAX_PATH;
8297     sprintf(path, "%s\\FileName1", CURR_DIR);
8298     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8299     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8300     if (space)
8301         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8302     else
8303         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8304
8305     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8306     RegDeleteValueA(hklm, "Value1");
8307     RegDeleteValueA(hklm, "Value2");
8308     RegDeleteValueA(hklm, "Value3");
8309     RegDeleteValueA(hklm, "Value4");
8310     RegDeleteValueA(hklm, "Value5");
8311     RegDeleteValueA(hklm, "Value6");
8312     RegDeleteValueA(hklm, "Value7");
8313     RegDeleteValueA(hklm, "Value8");
8314     RegDeleteValueA(hklm, "Value9");
8315     RegDeleteValueA(hklm, "Value10");
8316     RegDeleteValueA(hklm, "Value11");
8317     RegDeleteValueA(hklm, "Value12");
8318     RegDeleteValueA(hklm, "Value13");
8319     RegDeleteValueA(hklm, "Value14");
8320     RegDeleteValueA(hklm, "Value15");
8321     RegDeleteValueA(hklm, "Value16");
8322     RegDeleteValueA(hklm, "Value17");
8323     RegDeleteKeyA(hklm, "");
8324     RegCloseKey(hklm);
8325
8326     RegDeleteValueA(classes, "Value1");
8327     RegDeleteKeyA(classes, "");
8328     RegCloseKey(classes);
8329
8330     RegDeleteValueA(hkcu, "Value1");
8331     RegDeleteKeyA(hkcu, "");
8332     RegCloseKey(hkcu);
8333
8334     RegDeleteValueA(users, "Value1");
8335     RegDeleteKeyA(users, "");
8336     RegCloseKey(users);
8337
8338     DeleteFileA("FileName1");
8339     DeleteFileA("FileName3.dll");
8340     DeleteFileA("FileName4.dll");
8341     DeleteFileA("FileName5.dll");
8342     MsiCloseHandle(hpkg);
8343     DeleteFileA(msifile);
8344 }
8345
8346 static void delete_win_ini(LPCSTR file)
8347 {
8348     CHAR path[MAX_PATH];
8349
8350     GetWindowsDirectoryA(path, MAX_PATH);
8351     lstrcatA(path, "\\");
8352     lstrcatA(path, file);
8353
8354     DeleteFileA(path);
8355 }
8356
8357 static void test_appsearch_inilocator(void)
8358 {
8359     MSIHANDLE hpkg, hdb;
8360     CHAR path[MAX_PATH];
8361     CHAR prop[MAX_PATH];
8362     BOOL version;
8363     LPCSTR str;
8364     LPSTR ptr;
8365     DWORD size;
8366     UINT r;
8367
8368     version = TRUE;
8369     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8370         version = FALSE;
8371
8372     DeleteFileA("test.dll");
8373
8374     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
8375
8376     create_test_file("FileName1");
8377     sprintf(path, "%s\\FileName1", CURR_DIR);
8378     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
8379
8380     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
8381
8382     sprintf(path, "%s\\IDontExist", CURR_DIR);
8383     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
8384
8385     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8386     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8387     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
8388
8389     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8390     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8391     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
8392
8393     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8394     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8395     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
8396
8397     hdb = create_package_db();
8398     ok(hdb, "Expected a valid database handle\n");
8399
8400     r = create_appsearch_table(hdb);
8401     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8402
8403     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8404     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8405
8406     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8408
8409     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8410     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8411
8412     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8414
8415     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8417
8418     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8419     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8420
8421     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8422     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8423
8424     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8425     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8426
8427     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8428     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8429
8430     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8431     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8432
8433     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8434     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8435
8436     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8438
8439     r = create_inilocator_table(hdb);
8440     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8441
8442     /* msidbLocatorTypeRawValue, field 1 */
8443     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
8444     r = add_inilocator_entry(hdb, str);
8445     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8446
8447     /* msidbLocatorTypeRawValue, field 2 */
8448     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
8449     r = add_inilocator_entry(hdb, str);
8450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8451
8452     /* msidbLocatorTypeRawValue, entire field */
8453     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
8454     r = add_inilocator_entry(hdb, str);
8455     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8456
8457     /* msidbLocatorTypeFile */
8458     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8459     r = add_inilocator_entry(hdb, str);
8460     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8461
8462     /* msidbLocatorTypeDirectory, file */
8463     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
8464     r = add_inilocator_entry(hdb, str);
8465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8466
8467     /* msidbLocatorTypeDirectory, directory */
8468     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
8469     r = add_inilocator_entry(hdb, str);
8470     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8471
8472     /* msidbLocatorTypeFile, file, no signature */
8473     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8474     r = add_inilocator_entry(hdb, str);
8475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8476
8477     /* msidbLocatorTypeFile, dir, no signature */
8478     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
8479     r = add_inilocator_entry(hdb, str);
8480     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8481
8482     /* msidbLocatorTypeFile, file does not exist */
8483     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
8484     r = add_inilocator_entry(hdb, str);
8485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8486
8487     /* msidbLocatorTypeFile, signature with version */
8488     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
8489     r = add_inilocator_entry(hdb, str);
8490     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8491
8492     /* msidbLocatorTypeFile, signature with version, ver > max */
8493     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
8494     r = add_inilocator_entry(hdb, str);
8495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8496
8497     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
8498     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
8499     r = add_inilocator_entry(hdb, str);
8500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8501
8502     r = create_signature_table(hdb);
8503     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8504
8505     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
8506     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8507
8508     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
8509     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8510
8511     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8512     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8513
8514     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8515     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8516
8517     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8518     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8519
8520     hpkg = package_from_db(hdb);
8521     ok(hpkg, "Expected a valid package handle\n");
8522
8523     r = MsiDoAction(hpkg, "AppSearch");
8524     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8525
8526     size = MAX_PATH;
8527     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8529     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
8530
8531     size = MAX_PATH;
8532     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8533     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8534     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
8535
8536     size = MAX_PATH;
8537     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8539     ok(!lstrcmpA(prop, "keydata,field2"),
8540        "Expected \"keydata,field2\", got \"%s\"\n", prop);
8541
8542     size = MAX_PATH;
8543     sprintf(path, "%s\\FileName1", CURR_DIR);
8544     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8545     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8546     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8547
8548     size = MAX_PATH;
8549     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8551     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8552
8553     size = MAX_PATH;
8554     sprintf(path, "%s\\", CURR_DIR);
8555     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8556     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8557     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8558
8559     size = MAX_PATH;
8560     sprintf(path, "%s\\", CURR_DIR);
8561     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8562     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8563     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8564
8565     size = MAX_PATH;
8566     lstrcpyA(path, CURR_DIR);
8567     ptr = strrchr(path, '\\');
8568     *(ptr + 1) = '\0';
8569     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8571     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8572
8573     size = MAX_PATH;
8574     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8576     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8577
8578     if (version)
8579     {
8580         size = MAX_PATH;
8581         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8582         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8583         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8584         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8585
8586         size = MAX_PATH;
8587         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8588         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8589         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8590
8591         size = MAX_PATH;
8592         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8593         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8594         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8595         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8596     }
8597
8598     delete_win_ini("IniFile.ini");
8599     DeleteFileA("FileName1");
8600     DeleteFileA("FileName2.dll");
8601     DeleteFileA("FileName3.dll");
8602     DeleteFileA("FileName4.dll");
8603     MsiCloseHandle(hpkg);
8604     DeleteFileA(msifile);
8605 }
8606
8607 /*
8608  * MSI AppSearch action on DrLocator table always returns absolute paths.
8609  * If a relative path was set, it returns the first absolute path that
8610  * matches or an empty string if it didn't find anything.
8611  * This helper function replicates this behaviour.
8612  */
8613 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
8614 {
8615     int i, size;
8616     DWORD attr, drives;
8617
8618     size = lstrlenA(relative);
8619     drives = GetLogicalDrives();
8620     lstrcpyA(absolute, "A:\\");
8621     for (i = 0; i < 26; absolute[0] = '\0', i++)
8622     {
8623         if (!(drives & (1 << i)))
8624             continue;
8625
8626         absolute[0] = 'A' + i;
8627         if (GetDriveType(absolute) != DRIVE_FIXED)
8628             continue;
8629
8630         lstrcpynA(absolute + 3, relative, size + 1);
8631         attr = GetFileAttributesA(absolute);
8632         if (attr != INVALID_FILE_ATTRIBUTES &&
8633             (attr & FILE_ATTRIBUTE_DIRECTORY))
8634         {
8635             if (absolute[3 + size - 1] != '\\')
8636                 lstrcatA(absolute, "\\");
8637             break;
8638         }
8639         absolute[3] = '\0';
8640     }
8641 }
8642
8643 static void test_appsearch_drlocator(void)
8644 {
8645     MSIHANDLE hpkg, hdb;
8646     CHAR path[MAX_PATH];
8647     CHAR prop[MAX_PATH];
8648     BOOL version;
8649     LPCSTR str;
8650     DWORD size;
8651     UINT r;
8652
8653     version = TRUE;
8654     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8655         version = FALSE;
8656
8657     DeleteFileA("test.dll");
8658
8659     create_test_file("FileName1");
8660     CreateDirectoryA("one", NULL);
8661     CreateDirectoryA("one\\two", NULL);
8662     CreateDirectoryA("one\\two\\three", NULL);
8663     create_test_file("one\\two\\three\\FileName2");
8664     CreateDirectoryA("another", NULL);
8665     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8666     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8667     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8668
8669     hdb = create_package_db();
8670     ok(hdb, "Expected a valid database handle\n");
8671
8672     r = create_appsearch_table(hdb);
8673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8674
8675     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8676     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8677
8678     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8680
8681     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8683
8684     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8685     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8686
8687     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8688     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8689
8690     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8691     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8692
8693     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8695
8696     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8697     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8698
8699     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8700     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8701
8702     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8703     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8704
8705     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8706     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8707
8708     r = create_drlocator_table(hdb);
8709     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8710
8711     /* no parent, full path, depth 0, signature */
8712     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
8713     r = add_drlocator_entry(hdb, path);
8714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8715
8716     /* no parent, full path, depth 0, no signature */
8717     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
8718     r = add_drlocator_entry(hdb, path);
8719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8720
8721     /* no parent, relative path, depth 0, no signature */
8722     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
8723     r = add_drlocator_entry(hdb, path);
8724     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8725
8726     /* no parent, full path, depth 2, signature */
8727     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
8728     r = add_drlocator_entry(hdb, path);
8729     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8730
8731     /* no parent, full path, depth 3, signature */
8732     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
8733     r = add_drlocator_entry(hdb, path);
8734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8735
8736     /* no parent, full path, depth 1, signature is dir */
8737     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
8738     r = add_drlocator_entry(hdb, path);
8739     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8740
8741     /* parent is in DrLocator, relative path, depth 0, signature */
8742     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
8743     r = add_drlocator_entry(hdb, path);
8744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8745
8746     /* no parent, full path, depth 0, signature w/ version */
8747     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
8748     r = add_drlocator_entry(hdb, path);
8749     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8750
8751     /* no parent, full path, depth 0, signature w/ version, ver > max */
8752     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
8753     r = add_drlocator_entry(hdb, path);
8754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8755
8756     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
8757     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
8758     r = add_drlocator_entry(hdb, path);
8759     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8760
8761     /* no parent, relative empty path, depth 0, no signature */
8762     sprintf(path, "'NewSignature11', '', '', 0");
8763     r = add_drlocator_entry(hdb, path);
8764     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8765
8766     r = create_signature_table(hdb);
8767     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8768
8769     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
8770     r = add_signature_entry(hdb, str);
8771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8772
8773     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
8774     r = add_signature_entry(hdb, str);
8775     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8776
8777     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
8778     r = add_signature_entry(hdb, str);
8779     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8780
8781     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
8782     r = add_signature_entry(hdb, str);
8783     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8784
8785     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
8786     r = add_signature_entry(hdb, str);
8787     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8788
8789     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8790     r = add_signature_entry(hdb, str);
8791     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8792
8793     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8794     r = add_signature_entry(hdb, str);
8795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8796
8797     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8798     r = add_signature_entry(hdb, str);
8799     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8800
8801     hpkg = package_from_db(hdb);
8802     ok(hpkg, "Expected a valid package handle\n");
8803
8804     r = MsiDoAction(hpkg, "AppSearch");
8805     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8806
8807     size = MAX_PATH;
8808     sprintf(path, "%s\\FileName1", CURR_DIR);
8809     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8811     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8812
8813     size = MAX_PATH;
8814     sprintf(path, "%s\\", CURR_DIR);
8815     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8817     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8818
8819     size = MAX_PATH;
8820     search_absolute_directory(path, CURR_DIR + 3);
8821     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8823     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8824
8825     size = MAX_PATH;
8826     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8827     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8828     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8829
8830     size = MAX_PATH;
8831     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
8832     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8833     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8834     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8835
8836     size = MAX_PATH;
8837     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8838     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8839     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8840
8841     size = MAX_PATH;
8842     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
8843     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8844     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8845     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8846
8847     if (version)
8848     {
8849         size = MAX_PATH;
8850         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8851         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8852         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8853         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8854
8855         size = MAX_PATH;
8856         r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8857         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8858         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8859
8860         size = MAX_PATH;
8861         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8862         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8863         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8864     }
8865
8866     size = MAX_PATH;
8867     search_absolute_directory(path, "");
8868     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8869     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8870     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8871
8872     DeleteFileA("FileName1");
8873     DeleteFileA("FileName3.dll");
8874     DeleteFileA("FileName4.dll");
8875     DeleteFileA("FileName5.dll");
8876     DeleteFileA("one\\two\\three\\FileName2");
8877     RemoveDirectoryA("one\\two\\three");
8878     RemoveDirectoryA("one\\two");
8879     RemoveDirectoryA("one");
8880     RemoveDirectoryA("another");
8881     MsiCloseHandle(hpkg);
8882     DeleteFileA(msifile);
8883 }
8884
8885 static void test_featureparents(void)
8886 {
8887     MSIHANDLE hpkg;
8888     UINT r;
8889     MSIHANDLE hdb;
8890     INSTALLSTATE state, action;
8891
8892     hdb = create_package_db();
8893     ok ( hdb, "failed to create package database\n" );
8894
8895     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
8896     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
8897
8898     r = create_feature_table( hdb );
8899     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
8900
8901     r = create_component_table( hdb );
8902     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
8903
8904     r = create_feature_components_table( hdb );
8905     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
8906
8907     r = create_file_table( hdb );
8908     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
8909
8910     /* msidbFeatureAttributesFavorLocal */
8911     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
8912     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8913
8914     /* msidbFeatureAttributesFavorSource */
8915     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
8916     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8917
8918     /* msidbFeatureAttributesFavorLocal */
8919     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
8920     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8921
8922     /* disabled because of install level */
8923     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
8924     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8925
8926     /* child feature of disabled feature */
8927     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
8928     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8929
8930     /* component of disabled feature (install level) */
8931     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
8932     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8933
8934     /* component of disabled child feature (install level) */
8935     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
8936     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8937
8938     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
8939     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
8940     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8941
8942     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
8943     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
8944     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8945
8946     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
8947     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
8948     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8949
8950     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
8951     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
8952     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8953
8954     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
8955     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
8956     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8957
8958     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
8959     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
8960     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8961
8962     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
8963     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
8964     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8965
8966     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
8967     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
8968     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8969
8970     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
8971     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
8972
8973     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
8974     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8975
8976     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
8977     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8978
8979     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
8980     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8981
8982     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
8983     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8984
8985     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
8986     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8987
8988     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
8989     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8990
8991     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
8992     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8993
8994     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
8995     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8996
8997     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
8998     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8999
9000     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
9001     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9002
9003     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
9004     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9005
9006     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
9007     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9008
9009     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
9010     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9011
9012     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
9013     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9014
9015     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
9016     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9017
9018     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
9019     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9020
9021     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
9022     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9023
9024     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
9025     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9026
9027     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
9028     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9029
9030     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9031     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9032
9033     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9034     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9035
9036     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9037     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9038
9039     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9040     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9041
9042     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9043     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9044
9045     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9046     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9047
9048     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9049     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9050
9051     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9052     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9053
9054     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9055     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9056
9057     hpkg = package_from_db( hdb );
9058     ok( hpkg, "failed to create package\n");
9059
9060     MsiCloseHandle( hdb );
9061
9062     r = MsiDoAction( hpkg, "CostInitialize");
9063     ok( r == ERROR_SUCCESS, "cost init failed\n");
9064
9065     r = MsiDoAction( hpkg, "FileCost");
9066     ok( r == ERROR_SUCCESS, "file cost failed\n");
9067
9068     r = MsiDoAction( hpkg, "CostFinalize");
9069     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9070
9071     state = 0xdeadbee;
9072     action = 0xdeadbee;
9073     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9074     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9075     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9076     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9077
9078     state = 0xdeadbee;
9079     action = 0xdeadbee;
9080     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9081     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9082     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9083     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9084
9085     state = 0xdeadbee;
9086     action = 0xdeadbee;
9087     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9088     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9089     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9090     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9091
9092     state = 0xdeadbee;
9093     action = 0xdeadbee;
9094     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9095     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9096     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9097     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9098
9099     state = 0xdeadbee;
9100     action = 0xdeadbee;
9101     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9102     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9103     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9104     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9105
9106     state = 0xdeadbee;
9107     action = 0xdeadbee;
9108     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9109     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9110     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9111     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9112
9113     state = 0xdeadbee;
9114     action = 0xdeadbee;
9115     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9116     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9117     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9118     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9119
9120     state = 0xdeadbee;
9121     action = 0xdeadbee;
9122     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9123     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9124     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9125     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9126
9127     state = 0xdeadbee;
9128     action = 0xdeadbee;
9129     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9130     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9131     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9132     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9133
9134     state = 0xdeadbee;
9135     action = 0xdeadbee;
9136     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9137     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9138     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9139     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9140
9141     state = 0xdeadbee;
9142     action = 0xdeadbee;
9143     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9144     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9145     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9146     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9147
9148     state = 0xdeadbee;
9149     action = 0xdeadbee;
9150     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9152     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9153     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9154
9155     state = 0xdeadbee;
9156     action = 0xdeadbee;
9157     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9159     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9160     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9161
9162     state = 0xdeadbee;
9163     action = 0xdeadbee;
9164     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9166     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9167     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9168
9169     state = 0xdeadbee;
9170     action = 0xdeadbee;
9171     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9172     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9173     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9174     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9175
9176     state = 0xdeadbee;
9177     action = 0xdeadbee;
9178     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9179     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9180     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9181     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9182
9183     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9184     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9185
9186     state = 0xdeadbee;
9187     action = 0xdeadbee;
9188     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9189     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9190     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9191     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9192
9193     state = 0xdeadbee;
9194     action = 0xdeadbee;
9195     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9196     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9197     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9198     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9199
9200     state = 0xdeadbee;
9201     action = 0xdeadbee;
9202     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9203     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9204     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9205     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9206
9207     state = 0xdeadbee;
9208     action = 0xdeadbee;
9209     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9210     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9211     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9212     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9213
9214     state = 0xdeadbee;
9215     action = 0xdeadbee;
9216     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9217     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9218     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9219     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9220
9221     state = 0xdeadbee;
9222     action = 0xdeadbee;
9223     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9224     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9225     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9226     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9227
9228     state = 0xdeadbee;
9229     action = 0xdeadbee;
9230     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9232     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9233     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9234
9235     state = 0xdeadbee;
9236     action = 0xdeadbee;
9237     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9239     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9240     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9241
9242     state = 0xdeadbee;
9243     action = 0xdeadbee;
9244     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9246     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9247     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9248
9249     state = 0xdeadbee;
9250     action = 0xdeadbee;
9251     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9252     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9253     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9254     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9255
9256     state = 0xdeadbee;
9257     action = 0xdeadbee;
9258     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9259     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9260     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9261     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9262
9263     state = 0xdeadbee;
9264     action = 0xdeadbee;
9265     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9266     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9267     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9268     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9269
9270     state = 0xdeadbee;
9271     action = 0xdeadbee;
9272     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9273     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9274     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9275     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9276
9277     state = 0xdeadbee;
9278     action = 0xdeadbee;
9279     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9280     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9281     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9282     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9283     
9284     MsiCloseHandle(hpkg);
9285     DeleteFileA(msifile);
9286 }
9287
9288 static void test_installprops(void)
9289 {
9290     MSIHANDLE hpkg, hdb;
9291     CHAR path[MAX_PATH];
9292     CHAR buf[MAX_PATH];
9293     DWORD size, type;
9294     LANGID langid;
9295     HKEY hkey1, hkey2;
9296     int res;
9297     UINT r;
9298
9299     GetCurrentDirectory(MAX_PATH, path);
9300     lstrcat(path, "\\");
9301     lstrcat(path, msifile);
9302
9303     hdb = create_package_db();
9304     ok( hdb, "failed to create database\n");
9305
9306     hpkg = package_from_db(hdb);
9307     ok( hpkg, "failed to create package\n");
9308
9309     MsiCloseHandle(hdb);
9310
9311     size = MAX_PATH;
9312     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
9313     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9314     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9315
9316     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
9317
9318     RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
9319
9320     size = MAX_PATH;
9321     type = REG_SZ;
9322     *path = '\0';
9323     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9324     {
9325         size = MAX_PATH;
9326         type = REG_SZ;
9327         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
9328     }
9329
9330     /* win9x doesn't set this */
9331     if (*path)
9332     {
9333         size = MAX_PATH;
9334         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
9335         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9336         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9337     }
9338
9339     size = MAX_PATH;
9340     type = REG_SZ;
9341     *path = '\0';
9342     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9343     {
9344         size = MAX_PATH;
9345         type = REG_SZ;
9346         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
9347     }
9348
9349     if (*path)
9350     {
9351         size = MAX_PATH;
9352         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
9353         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9354         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9355     }
9356
9357     size = MAX_PATH;
9358     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
9359     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9360     trace("VersionDatabase = %s\n", buf);
9361
9362     size = MAX_PATH;
9363     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
9364     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9365     trace("VersionMsi = %s\n", buf);
9366
9367     size = MAX_PATH;
9368     r = MsiGetProperty(hpkg, "Date", buf, &size);
9369     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9370     trace("Date = %s\n", buf);
9371
9372     size = MAX_PATH;
9373     r = MsiGetProperty(hpkg, "Time", buf, &size);
9374     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9375     trace("Time = %s\n", buf);
9376
9377     size = MAX_PATH;
9378     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
9379     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9380     trace("PackageCode = %s\n", buf);
9381
9382     langid = GetUserDefaultLangID();
9383     sprintf(path, "%d", langid);
9384
9385     size = MAX_PATH;
9386     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
9387     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
9388     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
9389
9390     res = GetSystemMetrics(SM_CXSCREEN);
9391     size = MAX_PATH;
9392     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
9393     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9394
9395     res = GetSystemMetrics(SM_CYSCREEN);
9396     size = MAX_PATH;
9397     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
9398     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9399
9400     CloseHandle(hkey1);
9401     CloseHandle(hkey2);
9402     MsiCloseHandle(hpkg);
9403     DeleteFile(msifile);
9404 }
9405
9406 static void test_launchconditions(void)
9407 {
9408     MSIHANDLE hpkg;
9409     MSIHANDLE hdb;
9410     UINT r;
9411
9412     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9413
9414     hdb = create_package_db();
9415     ok( hdb, "failed to create package database\n" );
9416
9417     r = create_launchcondition_table( hdb );
9418     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
9419
9420     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
9421     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9422
9423     /* invalid condition */
9424     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
9425     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9426
9427     hpkg = package_from_db( hdb );
9428     ok( hpkg, "failed to create package\n");
9429
9430     MsiCloseHandle( hdb );
9431
9432     r = MsiSetProperty( hpkg, "X", "1" );
9433     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9434
9435     /* invalid conditions are ignored */
9436     r = MsiDoAction( hpkg, "LaunchConditions" );
9437     ok( r == ERROR_SUCCESS, "cost init failed\n" );
9438
9439     /* verify LaunchConditions still does some verification */
9440     r = MsiSetProperty( hpkg, "X", "2" );
9441     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9442
9443     r = MsiDoAction( hpkg, "LaunchConditions" );
9444     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
9445
9446     MsiCloseHandle( hpkg );
9447     DeleteFile( msifile );
9448 }
9449
9450 static void test_ccpsearch(void)
9451 {
9452     MSIHANDLE hdb, hpkg;
9453     CHAR prop[MAX_PATH];
9454     DWORD size = MAX_PATH;
9455     UINT r;
9456
9457     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9458
9459     hdb = create_package_db();
9460     ok(hdb, "failed to create package database\n");
9461
9462     r = create_ccpsearch_table(hdb);
9463     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9464
9465     r = add_ccpsearch_entry(hdb, "'CCP_random'");
9466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9467
9468     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
9469     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9470
9471     r = create_reglocator_table(hdb);
9472     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9473
9474     r = add_reglocator_entry(hdb, "'CCP_random', 0, 'htmlfile\\shell\\open\\nonexistent', '', 1");
9475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9476
9477     r = create_drlocator_table(hdb);
9478     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9479
9480     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
9481     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9482
9483     r = create_signature_table(hdb);
9484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9485
9486     hpkg = package_from_db(hdb);
9487     ok(hpkg, "failed to create package\n");
9488
9489     MsiCloseHandle(hdb);
9490
9491     r = MsiDoAction(hpkg, "CCPSearch");
9492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9493
9494     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
9495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9496     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
9497
9498     MsiCloseHandle(hpkg);
9499     DeleteFileA(msifile);
9500 }
9501
9502 static void test_complocator(void)
9503 {
9504     MSIHANDLE hdb, hpkg;
9505     UINT r;
9506     CHAR prop[MAX_PATH];
9507     CHAR expected[MAX_PATH];
9508     DWORD size = MAX_PATH;
9509
9510     hdb = create_package_db();
9511     ok(hdb, "failed to create package database\n");
9512
9513     r = create_appsearch_table(hdb);
9514     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9515
9516     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
9517     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9518
9519     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
9520     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9521
9522     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
9523     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9524
9525     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
9526     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9527
9528     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
9529     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9530
9531     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
9532     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9533
9534     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
9535     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9536
9537     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
9538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9539
9540     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
9541     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9542
9543     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
9544     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9545
9546     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
9547     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9548
9549     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
9550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9551
9552     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
9553     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9554
9555     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
9556     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9557
9558     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
9559     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9560
9561     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
9562     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9563
9564     r = create_complocator_table(hdb);
9565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9566
9567     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
9568     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9569
9570     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
9571     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9572
9573     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
9574     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9575
9576     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
9577     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9578
9579     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
9580     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9581
9582     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
9583     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9584
9585     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
9586     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9587
9588     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
9589     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9590
9591     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
9592     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9593
9594     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
9595     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9596
9597     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
9598     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9599
9600     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
9601     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9602
9603     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
9604     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9605
9606     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
9607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9608
9609     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
9610     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9611
9612     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
9613     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9614
9615     r = create_signature_table(hdb);
9616     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9617
9618     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
9619     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9620
9621     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
9622     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9623
9624     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
9625     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9626
9627     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
9628     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9629
9630     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
9631     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9632
9633     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
9634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9635
9636     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
9637     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9638
9639     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
9640     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9641
9642     hpkg = package_from_db(hdb);
9643     ok(hpkg, "failed to create package\n");
9644
9645     MsiCloseHandle(hdb);
9646
9647     create_test_file("abelisaurus");
9648     create_test_file("bactrosaurus");
9649     create_test_file("camelotia");
9650     create_test_file("diclonius");
9651     create_test_file("echinodon");
9652     create_test_file("falcarius");
9653     create_test_file("gallimimus");
9654     create_test_file("hagryphus");
9655     CreateDirectoryA("iguanodon", NULL);
9656     CreateDirectoryA("jobaria", NULL);
9657     CreateDirectoryA("kakuru", NULL);
9658     CreateDirectoryA("labocania", NULL);
9659     CreateDirectoryA("megaraptor", NULL);
9660     CreateDirectoryA("neosodon", NULL);
9661     CreateDirectoryA("olorotitan", NULL);
9662     CreateDirectoryA("pantydraco", NULL);
9663
9664     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
9665                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
9666     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
9667                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
9668     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
9669                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
9670     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
9671                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
9672     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
9673                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
9674     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
9675                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
9676     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
9677                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
9678     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
9679                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
9680
9681     r = MsiDoAction(hpkg, "AppSearch");
9682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9683
9684     size = MAX_PATH;
9685     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
9686     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9687
9688     lstrcpyA(expected, CURR_DIR);
9689     lstrcatA(expected, "\\abelisaurus");
9690     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9691        "Expected %s or empty string, got %s\n", expected, prop);
9692
9693     size = MAX_PATH;
9694     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
9695     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9696     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9697
9698     size = MAX_PATH;
9699     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
9700     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9701     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9702
9703     size = MAX_PATH;
9704     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
9705     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9706     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9707
9708     size = MAX_PATH;
9709     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
9710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9711
9712     lstrcpyA(expected, CURR_DIR);
9713     lstrcatA(expected, "\\");
9714     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9715        "Expected %s or empty string, got %s\n", expected, prop);
9716
9717     size = MAX_PATH;
9718     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
9719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9720     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9721
9722     size = MAX_PATH;
9723     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
9724     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9725     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9726
9727     size = MAX_PATH;
9728     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
9729     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9730     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9731
9732     size = MAX_PATH;
9733     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
9734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9735     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9736
9737     size = MAX_PATH;
9738     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
9739     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9740     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9741
9742     size = MAX_PATH;
9743     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
9744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9745     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9746
9747     size = MAX_PATH;
9748     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
9749     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9750     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9751
9752     size = MAX_PATH;
9753     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
9754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9755
9756     lstrcpyA(expected, CURR_DIR);
9757     lstrcatA(expected, "\\");
9758     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9759        "Expected %s or empty string, got %s\n", expected, prop);
9760
9761     size = MAX_PATH;
9762     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
9763     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9764
9765     lstrcpyA(expected, CURR_DIR);
9766     lstrcatA(expected, "\\neosodon\\");
9767     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9768        "Expected %s or empty string, got %s\n", expected, prop);
9769
9770     size = MAX_PATH;
9771     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
9772     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9773     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9774
9775     size = MAX_PATH;
9776     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
9777     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9778     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9779
9780     MsiCloseHandle(hpkg);
9781     DeleteFileA("abelisaurus");
9782     DeleteFileA("bactrosaurus");
9783     DeleteFileA("camelotia");
9784     DeleteFileA("diclonius");
9785     DeleteFileA("echinodon");
9786     DeleteFileA("falcarius");
9787     DeleteFileA("gallimimus");
9788     DeleteFileA("hagryphus");
9789     RemoveDirectoryA("iguanodon");
9790     RemoveDirectoryA("jobaria");
9791     RemoveDirectoryA("kakuru");
9792     RemoveDirectoryA("labocania");
9793     RemoveDirectoryA("megaraptor");
9794     RemoveDirectoryA("neosodon");
9795     RemoveDirectoryA("olorotitan");
9796     RemoveDirectoryA("pantydraco");
9797     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
9798                           MSIINSTALLCONTEXT_MACHINE, NULL);
9799     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
9800                           MSIINSTALLCONTEXT_MACHINE, NULL);
9801     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
9802                           MSIINSTALLCONTEXT_MACHINE, NULL);
9803     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
9804                           MSIINSTALLCONTEXT_MACHINE, NULL);
9805     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
9806                           MSIINSTALLCONTEXT_MACHINE, NULL);
9807     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
9808                           MSIINSTALLCONTEXT_MACHINE, NULL);
9809     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
9810                           MSIINSTALLCONTEXT_MACHINE, NULL);
9811     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
9812                           MSIINSTALLCONTEXT_MACHINE, NULL);
9813     DeleteFileA(msifile);
9814 }
9815
9816 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
9817 {
9818     MSIHANDLE summary;
9819     UINT r;
9820
9821     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
9822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9823
9824     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
9825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9826
9827     r = MsiSummaryInfoPersist(summary);
9828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9829
9830     MsiCloseHandle(summary);
9831 }
9832
9833 static void test_MsiGetSourcePath(void)
9834 {
9835     MSIHANDLE hdb, hpkg;
9836     CHAR path[MAX_PATH];
9837     CHAR cwd[MAX_PATH];
9838     CHAR subsrc[MAX_PATH];
9839     CHAR sub2[MAX_PATH];
9840     DWORD size;
9841     UINT r;
9842
9843     lstrcpyA(cwd, CURR_DIR);
9844     lstrcatA(cwd, "\\");
9845
9846     lstrcpyA(subsrc, cwd);
9847     lstrcatA(subsrc, "subsource");
9848     lstrcatA(subsrc, "\\");
9849
9850     lstrcpyA(sub2, subsrc);
9851     lstrcatA(sub2, "sub2");
9852     lstrcatA(sub2, "\\");
9853
9854     /* uncompressed source */
9855
9856     hdb = create_package_db();
9857     ok( hdb, "failed to create database\n");
9858
9859     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
9860
9861     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
9862     ok(r == S_OK, "failed\n");
9863
9864     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
9865     ok(r == S_OK, "failed\n");
9866
9867     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
9868     ok(r == S_OK, "failed\n");
9869
9870     r = MsiDatabaseCommit(hdb);
9871     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
9872
9873     hpkg = package_from_db(hdb);
9874     ok(hpkg, "failed to create package\n");
9875
9876     MsiCloseHandle(hdb);
9877
9878     /* invalid database handle */
9879     size = MAX_PATH;
9880     lstrcpyA(path, "kiwi");
9881     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
9882     ok(r == ERROR_INVALID_HANDLE,
9883        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
9884     ok(!lstrcmpA(path, "kiwi"),
9885        "Expected path to be unchanged, got \"%s\"\n", path);
9886     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9887
9888     /* NULL szFolder */
9889     size = MAX_PATH;
9890     lstrcpyA(path, "kiwi");
9891     r = MsiGetSourcePath(hpkg, NULL, path, &size);
9892     ok(r == ERROR_INVALID_PARAMETER,
9893        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9894     ok(!lstrcmpA(path, "kiwi"),
9895        "Expected path to be unchanged, got \"%s\"\n", path);
9896     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9897
9898     /* empty szFolder */
9899     size = MAX_PATH;
9900     lstrcpyA(path, "kiwi");
9901     r = MsiGetSourcePath(hpkg, "", path, &size);
9902     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9903     ok(!lstrcmpA(path, "kiwi"),
9904        "Expected path to be unchanged, got \"%s\"\n", path);
9905     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9906
9907     /* try TARGETDIR */
9908     size = MAX_PATH;
9909     lstrcpyA(path, "kiwi");
9910     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
9911     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9912     ok(!lstrcmpA(path, "kiwi"),
9913        "Expected path to be unchanged, got \"%s\"\n", path);
9914     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9915
9916     /* try SourceDir */
9917     size = MAX_PATH;
9918     lstrcpyA(path, "kiwi");
9919     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
9920     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9921     ok(!lstrcmpA(path, "kiwi"),
9922        "Expected path to be unchanged, got \"%s\"\n", path);
9923     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9924
9925     /* try SOURCEDIR */
9926     size = MAX_PATH;
9927     lstrcpyA(path, "kiwi");
9928     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9929     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9930     ok(!lstrcmpA(path, "kiwi"),
9931        "Expected path to be unchanged, got \"%s\"\n", path);
9932     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9933
9934     /* source path does not exist, but the property exists */
9935     size = MAX_PATH;
9936     lstrcpyA(path, "kiwi");
9937     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9938     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9939     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9940     ok(size == 0, "Expected 0, got %d\n", size);
9941
9942     /* try SubDir */
9943     size = MAX_PATH;
9944     lstrcpyA(path, "kiwi");
9945     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
9946     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9947     ok(!lstrcmpA(path, "kiwi"),
9948        "Expected path to be unchanged, got \"%s\"\n", path);
9949     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9950
9951     /* try SubDir2 */
9952     size = MAX_PATH;
9953     lstrcpyA(path, "kiwi");
9954     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
9955     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9956     ok(!lstrcmpA(path, "kiwi"),
9957        "Expected path to be unchanged, got \"%s\"\n", path);
9958     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9959
9960     r = MsiDoAction(hpkg, "CostInitialize");
9961     ok(r == ERROR_SUCCESS, "cost init failed\n");
9962
9963     /* try TARGETDIR after CostInitialize */
9964     size = MAX_PATH;
9965     lstrcpyA(path, "kiwi");
9966     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
9967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9968     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9969     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9970
9971     /* try SourceDir after CostInitialize */
9972     size = MAX_PATH;
9973     lstrcpyA(path, "kiwi");
9974     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
9975     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9976     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9977     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9978
9979     /* try SOURCEDIR after CostInitialize */
9980     size = MAX_PATH;
9981     lstrcpyA(path, "kiwi");
9982     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9983     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9984     ok(!lstrcmpA(path, "kiwi"),
9985        "Expected path to be unchanged, got \"%s\"\n", path);
9986     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9987
9988     /* source path does not exist, but the property exists */
9989     size = MAX_PATH;
9990     lstrcpyA(path, "kiwi");
9991     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9992     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9993     todo_wine
9994     {
9995         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9996         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9997     }
9998
9999     /* try SubDir after CostInitialize */
10000     size = MAX_PATH;
10001     lstrcpyA(path, "kiwi");
10002     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10004     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10005     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10006
10007     /* try SubDir2 after CostInitialize */
10008     size = MAX_PATH;
10009     lstrcpyA(path, "kiwi");
10010     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10011     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10012     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10013     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10014
10015     r = MsiDoAction(hpkg, "ResolveSource");
10016     ok(r == ERROR_SUCCESS, "file cost failed\n");
10017
10018     /* try TARGETDIR after ResolveSource */
10019     size = MAX_PATH;
10020     lstrcpyA(path, "kiwi");
10021     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10022     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10023     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10024     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10025
10026     /* try SourceDir after ResolveSource */
10027     size = MAX_PATH;
10028     lstrcpyA(path, "kiwi");
10029     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10030     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10031     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10032     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10033
10034     /* try SOURCEDIR after ResolveSource */
10035     size = MAX_PATH;
10036     lstrcpyA(path, "kiwi");
10037     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10038     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10039     ok(!lstrcmpA(path, "kiwi"),
10040        "Expected path to be unchanged, got \"%s\"\n", path);
10041     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10042
10043     /* source path does not exist, but the property exists */
10044     size = MAX_PATH;
10045     lstrcpyA(path, "kiwi");
10046     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10048     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10049     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10050
10051     /* try SubDir after ResolveSource */
10052     size = MAX_PATH;
10053     lstrcpyA(path, "kiwi");
10054     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10056     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10057     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10058
10059     /* try SubDir2 after ResolveSource */
10060     size = MAX_PATH;
10061     lstrcpyA(path, "kiwi");
10062     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10063     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10064     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10065     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10066
10067     r = MsiDoAction(hpkg, "FileCost");
10068     ok(r == ERROR_SUCCESS, "file cost failed\n");
10069
10070     /* try TARGETDIR after FileCost */
10071     size = MAX_PATH;
10072     lstrcpyA(path, "kiwi");
10073     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10074     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10075     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10076     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10077
10078     /* try SourceDir after FileCost */
10079     size = MAX_PATH;
10080     lstrcpyA(path, "kiwi");
10081     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10082     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10083     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10084     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10085
10086     /* try SOURCEDIR after FileCost */
10087     size = MAX_PATH;
10088     lstrcpyA(path, "kiwi");
10089     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10090     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10091     ok(!lstrcmpA(path, "kiwi"),
10092        "Expected path to be unchanged, got \"%s\"\n", path);
10093     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10094
10095     /* source path does not exist, but the property exists */
10096     size = MAX_PATH;
10097     lstrcpyA(path, "kiwi");
10098     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10100     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10101     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10102
10103     /* try SubDir after FileCost */
10104     size = MAX_PATH;
10105     lstrcpyA(path, "kiwi");
10106     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10108     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10109     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10110
10111     /* try SubDir2 after FileCost */
10112     size = MAX_PATH;
10113     lstrcpyA(path, "kiwi");
10114     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10115     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10116     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10117     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10118
10119     r = MsiDoAction(hpkg, "CostFinalize");
10120     ok(r == ERROR_SUCCESS, "file cost failed\n");
10121
10122     /* try TARGETDIR after CostFinalize */
10123     size = MAX_PATH;
10124     lstrcpyA(path, "kiwi");
10125     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10126     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10127     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10128     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10129
10130     /* try SourceDir after CostFinalize */
10131     size = MAX_PATH;
10132     lstrcpyA(path, "kiwi");
10133     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10134     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10135     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10136     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10137
10138     /* try SOURCEDIR after CostFinalize */
10139     size = MAX_PATH;
10140     lstrcpyA(path, "kiwi");
10141     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10142     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10143     ok(!lstrcmpA(path, "kiwi"),
10144        "Expected path to be unchanged, got \"%s\"\n", path);
10145     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10146
10147     /* source path does not exist, but the property exists */
10148     size = MAX_PATH;
10149     lstrcpyA(path, "kiwi");
10150     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10151     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10152     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10153     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10154
10155     /* try SubDir after CostFinalize */
10156     size = MAX_PATH;
10157     lstrcpyA(path, "kiwi");
10158     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10159     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10160     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10161     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10162
10163     /* try SubDir2 after CostFinalize */
10164     size = MAX_PATH;
10165     lstrcpyA(path, "kiwi");
10166     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10167     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10168     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10169     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10170
10171     /* nonexistent directory */
10172     size = MAX_PATH;
10173     lstrcpyA(path, "kiwi");
10174     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
10175     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10176     ok(!lstrcmpA(path, "kiwi"),
10177        "Expected path to be unchanged, got \"%s\"\n", path);
10178     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10179
10180     /* NULL szPathBuf */
10181     size = MAX_PATH;
10182     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
10183     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10184     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10185
10186     /* NULL pcchPathBuf */
10187     lstrcpyA(path, "kiwi");
10188     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
10189     ok(r == ERROR_INVALID_PARAMETER,
10190        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10191     ok(!lstrcmpA(path, "kiwi"),
10192        "Expected path to be unchanged, got \"%s\"\n", path);
10193
10194     /* pcchPathBuf is 0 */
10195     size = 0;
10196     lstrcpyA(path, "kiwi");
10197     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10198     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10199     ok(!lstrcmpA(path, "kiwi"),
10200        "Expected path to be unchanged, got \"%s\"\n", path);
10201     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10202
10203     /* pcchPathBuf does not have room for NULL terminator */
10204     size = lstrlenA(cwd);
10205     lstrcpyA(path, "kiwi");
10206     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10207     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10208     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
10209        "Expected path with no backslash, got \"%s\"\n", path);
10210     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10211
10212     /* pcchPathBuf has room for NULL terminator */
10213     size = lstrlenA(cwd) + 1;
10214     lstrcpyA(path, "kiwi");
10215     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10216     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10217     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10218     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10219
10220     MsiCloseHandle(hpkg);
10221
10222     /* compressed source */
10223
10224     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
10225     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10226
10227     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
10228
10229     hpkg = package_from_db(hdb);
10230     ok(hpkg, "failed to create package\n");
10231
10232     /* try TARGETDIR */
10233     size = MAX_PATH;
10234     lstrcpyA(path, "kiwi");
10235     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10236     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10237     ok(!lstrcmpA(path, "kiwi"),
10238        "Expected path to be unchanged, got \"%s\"\n", path);
10239     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10240
10241     /* try SourceDir */
10242     size = MAX_PATH;
10243     lstrcpyA(path, "kiwi");
10244     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10245     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10246     ok(!lstrcmpA(path, "kiwi"),
10247        "Expected path to be unchanged, got \"%s\"\n", path);
10248     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10249
10250     /* try SOURCEDIR */
10251     size = MAX_PATH;
10252     lstrcpyA(path, "kiwi");
10253     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10254     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10255     ok(!lstrcmpA(path, "kiwi"),
10256        "Expected path to be unchanged, got \"%s\"\n", path);
10257     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10258
10259     /* source path nor the property exist */
10260     size = MAX_PATH;
10261     lstrcpyA(path, "kiwi");
10262     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10263     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10264     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10265     ok(size == 0, "Expected 0, got %d\n", size);
10266
10267     /* try SubDir */
10268     size = MAX_PATH;
10269     lstrcpyA(path, "kiwi");
10270     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10271     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10272     ok(!lstrcmpA(path, "kiwi"),
10273        "Expected path to be unchanged, got \"%s\"\n", path);
10274     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10275
10276     /* try SubDir2 */
10277     size = MAX_PATH;
10278     lstrcpyA(path, "kiwi");
10279     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10280     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10281     ok(!lstrcmpA(path, "kiwi"),
10282        "Expected path to be unchanged, got \"%s\"\n", path);
10283     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10284
10285     r = MsiDoAction(hpkg, "CostInitialize");
10286     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10287
10288     /* try TARGETDIR after CostInitialize */
10289     size = MAX_PATH;
10290     lstrcpyA(path, "kiwi");
10291     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10292     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10293     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10294     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10295
10296     /* try SourceDir after CostInitialize */
10297     size = MAX_PATH;
10298     lstrcpyA(path, "kiwi");
10299     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10301     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10302     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10303
10304     /* try SOURCEDIR after CostInitialize */
10305     size = MAX_PATH;
10306     lstrcpyA(path, "kiwi");
10307     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10308     todo_wine
10309     {
10310         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10311         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10312         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10313     }
10314
10315     /* source path does not exist, but the property exists */
10316     size = MAX_PATH;
10317     lstrcpyA(path, "kiwi");
10318     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10319     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10320     todo_wine
10321     {
10322         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10323         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10324     }
10325
10326     /* try SubDir after CostInitialize */
10327     size = MAX_PATH;
10328     lstrcpyA(path, "kiwi");
10329     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10330     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10331     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10332     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10333
10334     /* try SubDir2 after CostInitialize */
10335     size = MAX_PATH;
10336     lstrcpyA(path, "kiwi");
10337     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10338     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10339     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10340     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10341
10342     r = MsiDoAction(hpkg, "ResolveSource");
10343     ok(r == ERROR_SUCCESS, "file cost failed\n");
10344
10345     /* try TARGETDIR after ResolveSource */
10346     size = MAX_PATH;
10347     lstrcpyA(path, "kiwi");
10348     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10349     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10350     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10351     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10352
10353     /* try SourceDir after ResolveSource */
10354     size = MAX_PATH;
10355     lstrcpyA(path, "kiwi");
10356     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10357     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10358     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10359     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10360
10361     /* try SOURCEDIR after ResolveSource */
10362     size = MAX_PATH;
10363     lstrcpyA(path, "kiwi");
10364     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10365     todo_wine
10366     {
10367         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10368         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10369         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10370     }
10371
10372     /* source path and the property exist */
10373     size = MAX_PATH;
10374     lstrcpyA(path, "kiwi");
10375     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10376     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10377     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10378     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10379
10380     /* try SubDir after ResolveSource */
10381     size = MAX_PATH;
10382     lstrcpyA(path, "kiwi");
10383     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10384     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10385     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10386     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10387
10388     /* try SubDir2 after ResolveSource */
10389     size = MAX_PATH;
10390     lstrcpyA(path, "kiwi");
10391     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10392     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10393     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10394     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10395
10396     r = MsiDoAction(hpkg, "FileCost");
10397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10398
10399     /* try TARGETDIR after CostFinalize */
10400     size = MAX_PATH;
10401     lstrcpyA(path, "kiwi");
10402     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10404     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10405     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10406
10407     /* try SourceDir after CostFinalize */
10408     size = MAX_PATH;
10409     lstrcpyA(path, "kiwi");
10410     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10411     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10412     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10413     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10414
10415     /* try SOURCEDIR after CostFinalize */
10416     size = MAX_PATH;
10417     lstrcpyA(path, "kiwi");
10418     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10419     todo_wine
10420     {
10421         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10422         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10423         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10424     }
10425
10426     /* source path and the property exist */
10427     size = MAX_PATH;
10428     lstrcpyA(path, "kiwi");
10429     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10431     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10432     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10433
10434     /* try SubDir after CostFinalize */
10435     size = MAX_PATH;
10436     lstrcpyA(path, "kiwi");
10437     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10438     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10439     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10440     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10441
10442     /* try SubDir2 after CostFinalize */
10443     size = MAX_PATH;
10444     lstrcpyA(path, "kiwi");
10445     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10446     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10447     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10448     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10449
10450     r = MsiDoAction(hpkg, "CostFinalize");
10451     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10452
10453     /* try TARGETDIR after CostFinalize */
10454     size = MAX_PATH;
10455     lstrcpyA(path, "kiwi");
10456     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10457     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10458     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10459     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10460
10461     /* try SourceDir after CostFinalize */
10462     size = MAX_PATH;
10463     lstrcpyA(path, "kiwi");
10464     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10466     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10467     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10468
10469     /* try SOURCEDIR after CostFinalize */
10470     size = MAX_PATH;
10471     lstrcpyA(path, "kiwi");
10472     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10473     todo_wine
10474     {
10475         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10476         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10477         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10478     }
10479
10480     /* source path and the property exist */
10481     size = MAX_PATH;
10482     lstrcpyA(path, "kiwi");
10483     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10485     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10486     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10487
10488     /* try SubDir after CostFinalize */
10489     size = MAX_PATH;
10490     lstrcpyA(path, "kiwi");
10491     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10493     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10494     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10495
10496     /* try SubDir2 after CostFinalize */
10497     size = MAX_PATH;
10498     lstrcpyA(path, "kiwi");
10499     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10501     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10502     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10503
10504     MsiCloseHandle(hpkg);
10505     DeleteFile(msifile);
10506 }
10507
10508 static void test_shortlongsource(void)
10509 {
10510     MSIHANDLE hdb, hpkg;
10511     CHAR path[MAX_PATH];
10512     CHAR cwd[MAX_PATH];
10513     CHAR subsrc[MAX_PATH];
10514     DWORD size;
10515     UINT r;
10516
10517     lstrcpyA(cwd, CURR_DIR);
10518     lstrcatA(cwd, "\\");
10519
10520     lstrcpyA(subsrc, cwd);
10521     lstrcatA(subsrc, "long");
10522     lstrcatA(subsrc, "\\");
10523
10524     /* long file names */
10525
10526     hdb = create_package_db();
10527     ok( hdb, "failed to create database\n");
10528
10529     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10530
10531     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10532     ok(r == S_OK, "failed\n");
10533
10534     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
10535     ok(r == S_OK, "failed\n");
10536
10537     /* CostInitialize:short */
10538     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
10539     ok(r == S_OK, "failed\n");
10540
10541     /* CostInitialize:long */
10542     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
10543     ok(r == S_OK, "failed\n");
10544
10545     /* FileCost:short */
10546     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
10547     ok(r == S_OK, "failed\n");
10548
10549     /* FileCost:long */
10550     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
10551     ok(r == S_OK, "failed\n");
10552
10553     /* CostFinalize:short */
10554     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
10555     ok(r == S_OK, "failed\n");
10556
10557     /* CostFinalize:long */
10558     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
10559     ok(r == S_OK, "failed\n");
10560
10561     MsiDatabaseCommit(hdb);
10562
10563     hpkg = package_from_db(hdb);
10564     ok(hpkg, "failed to create package\n");
10565
10566     MsiCloseHandle(hdb);
10567
10568     CreateDirectoryA("one", NULL);
10569     CreateDirectoryA("four", NULL);
10570
10571     r = MsiDoAction(hpkg, "CostInitialize");
10572     ok(r == ERROR_SUCCESS, "file cost failed\n");
10573
10574     CreateDirectory("five", NULL);
10575     CreateDirectory("eight", NULL);
10576
10577     r = MsiDoAction(hpkg, "FileCost");
10578     ok(r == ERROR_SUCCESS, "file cost failed\n");
10579
10580     CreateDirectory("nine", NULL);
10581     CreateDirectory("twelve", NULL);
10582
10583     r = MsiDoAction(hpkg, "CostFinalize");
10584     ok(r == ERROR_SUCCESS, "file cost failed\n");
10585
10586     /* neither short nor long source directories exist */
10587     size = MAX_PATH;
10588     lstrcpyA(path, "kiwi");
10589     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10590     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10591     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10592     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10593
10594     CreateDirectoryA("short", NULL);
10595
10596     /* short source directory exists */
10597     size = MAX_PATH;
10598     lstrcpyA(path, "kiwi");
10599     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10600     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10601     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10602     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10603
10604     CreateDirectoryA("long", NULL);
10605
10606     /* both short and long source directories exist */
10607     size = MAX_PATH;
10608     lstrcpyA(path, "kiwi");
10609     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10610     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10611     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10612     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10613
10614     lstrcpyA(subsrc, cwd);
10615     lstrcatA(subsrc, "two");
10616     lstrcatA(subsrc, "\\");
10617
10618     /* short dir exists before CostInitialize */
10619     size = MAX_PATH;
10620     lstrcpyA(path, "kiwi");
10621     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10622     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10623     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10624     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10625
10626     lstrcpyA(subsrc, cwd);
10627     lstrcatA(subsrc, "four");
10628     lstrcatA(subsrc, "\\");
10629
10630     /* long dir exists before CostInitialize */
10631     size = MAX_PATH;
10632     lstrcpyA(path, "kiwi");
10633     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
10634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10635     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10636     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10637
10638     lstrcpyA(subsrc, cwd);
10639     lstrcatA(subsrc, "six");
10640     lstrcatA(subsrc, "\\");
10641
10642     /* short dir exists before FileCost */
10643     size = MAX_PATH;
10644     lstrcpyA(path, "kiwi");
10645     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
10646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10647     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10648     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10649
10650     lstrcpyA(subsrc, cwd);
10651     lstrcatA(subsrc, "eight");
10652     lstrcatA(subsrc, "\\");
10653
10654     /* long dir exists before FileCost */
10655     size = MAX_PATH;
10656     lstrcpyA(path, "kiwi");
10657     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
10658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10659     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10660     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10661
10662     lstrcpyA(subsrc, cwd);
10663     lstrcatA(subsrc, "ten");
10664     lstrcatA(subsrc, "\\");
10665
10666     /* short dir exists before CostFinalize */
10667     size = MAX_PATH;
10668     lstrcpyA(path, "kiwi");
10669     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
10670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10671     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10672     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10673
10674     lstrcpyA(subsrc, cwd);
10675     lstrcatA(subsrc, "twelve");
10676     lstrcatA(subsrc, "\\");
10677
10678     /* long dir exists before CostFinalize */
10679     size = MAX_PATH;
10680     lstrcpyA(path, "kiwi");
10681     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
10682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10683     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10684     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10685
10686     MsiCloseHandle(hpkg);
10687     RemoveDirectoryA("short");
10688     RemoveDirectoryA("long");
10689     RemoveDirectoryA("one");
10690     RemoveDirectoryA("four");
10691     RemoveDirectoryA("five");
10692     RemoveDirectoryA("eight");
10693     RemoveDirectoryA("nine");
10694     RemoveDirectoryA("twelve");
10695
10696     /* short file names */
10697
10698     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
10699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10700
10701     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
10702
10703     hpkg = package_from_db(hdb);
10704     ok(hpkg, "failed to create package\n");
10705
10706     MsiCloseHandle(hdb);
10707
10708     CreateDirectoryA("one", NULL);
10709     CreateDirectoryA("four", NULL);
10710
10711     r = MsiDoAction(hpkg, "CostInitialize");
10712     ok(r == ERROR_SUCCESS, "file cost failed\n");
10713
10714     CreateDirectory("five", NULL);
10715     CreateDirectory("eight", NULL);
10716
10717     r = MsiDoAction(hpkg, "FileCost");
10718     ok(r == ERROR_SUCCESS, "file cost failed\n");
10719
10720     CreateDirectory("nine", NULL);
10721     CreateDirectory("twelve", NULL);
10722
10723     r = MsiDoAction(hpkg, "CostFinalize");
10724     ok(r == ERROR_SUCCESS, "file cost failed\n");
10725
10726     lstrcpyA(subsrc, cwd);
10727     lstrcatA(subsrc, "short");
10728     lstrcatA(subsrc, "\\");
10729
10730     /* neither short nor long source directories exist */
10731     size = MAX_PATH;
10732     lstrcpyA(path, "kiwi");
10733     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10735     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10736     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10737
10738     CreateDirectoryA("short", NULL);
10739
10740     /* short source directory exists */
10741     size = MAX_PATH;
10742     lstrcpyA(path, "kiwi");
10743     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10745     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10746     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10747
10748     CreateDirectoryA("long", NULL);
10749
10750     /* both short and long source directories exist */
10751     size = MAX_PATH;
10752     lstrcpyA(path, "kiwi");
10753     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10755     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10756     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10757
10758     lstrcpyA(subsrc, cwd);
10759     lstrcatA(subsrc, "one");
10760     lstrcatA(subsrc, "\\");
10761
10762     /* short dir exists before CostInitialize */
10763     size = MAX_PATH;
10764     lstrcpyA(path, "kiwi");
10765     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10767     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10768     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10769
10770     lstrcpyA(subsrc, cwd);
10771     lstrcatA(subsrc, "three");
10772     lstrcatA(subsrc, "\\");
10773
10774     /* long dir exists before CostInitialize */
10775     size = MAX_PATH;
10776     lstrcpyA(path, "kiwi");
10777     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
10778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10779     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10780     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10781
10782     lstrcpyA(subsrc, cwd);
10783     lstrcatA(subsrc, "five");
10784     lstrcatA(subsrc, "\\");
10785
10786     /* short dir exists before FileCost */
10787     size = MAX_PATH;
10788     lstrcpyA(path, "kiwi");
10789     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
10790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10791     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10792     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10793
10794     lstrcpyA(subsrc, cwd);
10795     lstrcatA(subsrc, "seven");
10796     lstrcatA(subsrc, "\\");
10797
10798     /* long dir exists before FileCost */
10799     size = MAX_PATH;
10800     lstrcpyA(path, "kiwi");
10801     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
10802     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10803     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10804     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10805
10806     lstrcpyA(subsrc, cwd);
10807     lstrcatA(subsrc, "nine");
10808     lstrcatA(subsrc, "\\");
10809
10810     /* short dir exists before CostFinalize */
10811     size = MAX_PATH;
10812     lstrcpyA(path, "kiwi");
10813     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
10814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10815     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10816     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10817
10818     lstrcpyA(subsrc, cwd);
10819     lstrcatA(subsrc, "eleven");
10820     lstrcatA(subsrc, "\\");
10821
10822     /* long dir exists before CostFinalize */
10823     size = MAX_PATH;
10824     lstrcpyA(path, "kiwi");
10825     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
10826     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10827     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10828     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10829
10830     MsiCloseHandle(hpkg);
10831     RemoveDirectoryA("short");
10832     RemoveDirectoryA("long");
10833     RemoveDirectoryA("one");
10834     RemoveDirectoryA("four");
10835     RemoveDirectoryA("five");
10836     RemoveDirectoryA("eight");
10837     RemoveDirectoryA("nine");
10838     RemoveDirectoryA("twelve");
10839     DeleteFileA(msifile);
10840 }
10841
10842 static void test_sourcedir(void)
10843 {
10844     MSIHANDLE hdb, hpkg;
10845     CHAR package[10];
10846     CHAR path[MAX_PATH];
10847     CHAR cwd[MAX_PATH];
10848     CHAR subsrc[MAX_PATH];
10849     DWORD size;
10850     UINT r;
10851
10852     lstrcpyA(cwd, CURR_DIR);
10853     lstrcatA(cwd, "\\");
10854
10855     lstrcpyA(subsrc, cwd);
10856     lstrcatA(subsrc, "long");
10857     lstrcatA(subsrc, "\\");
10858
10859     hdb = create_package_db();
10860     ok( hdb, "failed to create database\n");
10861
10862     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10863     ok(r == S_OK, "failed\n");
10864
10865     sprintf(package, "#%i", hdb);
10866     r = MsiOpenPackage(package, &hpkg);
10867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10868
10869     /* properties only */
10870
10871     /* SourceDir prop */
10872     size = MAX_PATH;
10873     lstrcpyA(path, "kiwi");
10874     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10875     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10876     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10877     ok(size == 0, "Expected 0, got %d\n", size);
10878
10879     /* SOURCEDIR prop */
10880     size = MAX_PATH;
10881     lstrcpyA(path, "kiwi");
10882     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10883     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10884     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10885     ok(size == 0, "Expected 0, got %d\n", size);
10886
10887     r = MsiDoAction(hpkg, "CostInitialize");
10888     ok(r == ERROR_SUCCESS, "file cost failed\n");
10889
10890     /* SourceDir after CostInitialize */
10891     size = MAX_PATH;
10892     lstrcpyA(path, "kiwi");
10893     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10895     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10896     ok(size == 0, "Expected 0, got %d\n", size);
10897
10898     /* SOURCEDIR after CostInitialize */
10899     size = MAX_PATH;
10900     lstrcpyA(path, "kiwi");
10901     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10902     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10903     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10904     ok(size == 0, "Expected 0, got %d\n", size);
10905
10906     r = MsiDoAction(hpkg, "FileCost");
10907     ok(r == ERROR_SUCCESS, "file cost failed\n");
10908
10909     /* SourceDir after FileCost */
10910     size = MAX_PATH;
10911     lstrcpyA(path, "kiwi");
10912     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10914     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10915     ok(size == 0, "Expected 0, got %d\n", size);
10916
10917     /* SOURCEDIR after FileCost */
10918     size = MAX_PATH;
10919     lstrcpyA(path, "kiwi");
10920     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10921     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10922     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10923     ok(size == 0, "Expected 0, got %d\n", size);
10924
10925     r = MsiDoAction(hpkg, "CostFinalize");
10926     ok(r == ERROR_SUCCESS, "file cost failed\n");
10927
10928     /* SourceDir after CostFinalize */
10929     size = MAX_PATH;
10930     lstrcpyA(path, "kiwi");
10931     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10932     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10933     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10934     ok(size == 0, "Expected 0, got %d\n", size);
10935
10936     /* SOURCEDIR after CostFinalize */
10937     size = MAX_PATH;
10938     lstrcpyA(path, "kiwi");
10939     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10940     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10941     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10942     ok(size == 0, "Expected 0, got %d\n", size);
10943
10944     r = MsiDoAction(hpkg, "ResolveSource");
10945     ok(r == ERROR_SUCCESS, "file cost failed\n");
10946
10947     /* SourceDir after ResolveSource */
10948     size = MAX_PATH;
10949     lstrcpyA(path, "kiwi");
10950     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10951     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10952     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10953     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10954
10955     /* SOURCEDIR after ResolveSource */
10956     size = MAX_PATH;
10957     lstrcpyA(path, "kiwi");
10958     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10959     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10960     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10961     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10962
10963     /* random casing */
10964     size = MAX_PATH;
10965     lstrcpyA(path, "kiwi");
10966     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
10967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10968     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10969     ok(size == 0, "Expected 0, got %d\n", size);
10970
10971     MsiCloseHandle(hpkg);
10972
10973     /* reset the package state */
10974     sprintf(package, "#%i", hdb);
10975     r = MsiOpenPackage(package, &hpkg);
10976     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10977
10978     /* test how MsiGetSourcePath affects the properties */
10979
10980     /* SourceDir prop */
10981     size = MAX_PATH;
10982     lstrcpyA(path, "kiwi");
10983     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10984     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10985     todo_wine
10986     {
10987         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10988         ok(size == 0, "Expected 0, got %d\n", size);
10989     }
10990
10991     size = MAX_PATH;
10992     lstrcpyA(path, "kiwi");
10993     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10994     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10995     ok(!lstrcmpA(path, "kiwi"),
10996        "Expected path to be unchanged, got \"%s\"\n", path);
10997     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10998
10999     /* SourceDir after MsiGetSourcePath */
11000     size = MAX_PATH;
11001     lstrcpyA(path, "kiwi");
11002     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11004     todo_wine
11005     {
11006         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11007         ok(size == 0, "Expected 0, got %d\n", size);
11008     }
11009
11010     /* SOURCEDIR prop */
11011     size = MAX_PATH;
11012     lstrcpyA(path, "kiwi");
11013     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11014     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11015     todo_wine
11016     {
11017         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11018         ok(size == 0, "Expected 0, got %d\n", size);
11019     }
11020
11021     size = MAX_PATH;
11022     lstrcpyA(path, "kiwi");
11023     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11024     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11025     ok(!lstrcmpA(path, "kiwi"),
11026        "Expected path to be unchanged, got \"%s\"\n", path);
11027     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11028
11029     /* SOURCEDIR prop after MsiGetSourcePath */
11030     size = MAX_PATH;
11031     lstrcpyA(path, "kiwi");
11032     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11034     todo_wine
11035     {
11036         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11037         ok(size == 0, "Expected 0, got %d\n", size);
11038     }
11039
11040     r = MsiDoAction(hpkg, "CostInitialize");
11041     ok(r == ERROR_SUCCESS, "file cost failed\n");
11042
11043     /* SourceDir after CostInitialize */
11044     size = MAX_PATH;
11045     lstrcpyA(path, "kiwi");
11046     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11048     todo_wine
11049     {
11050         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11051         ok(size == 0, "Expected 0, got %d\n", size);
11052     }
11053
11054     size = MAX_PATH;
11055     lstrcpyA(path, "kiwi");
11056     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11057     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11058     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11059     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11060
11061     /* SourceDir after MsiGetSourcePath */
11062     size = MAX_PATH;
11063     lstrcpyA(path, "kiwi");
11064     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11066     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11067     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11068
11069     /* SOURCEDIR after CostInitialize */
11070     size = MAX_PATH;
11071     lstrcpyA(path, "kiwi");
11072     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11073     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11074     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11075     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11076
11077     /* SOURCEDIR source path still does not exist */
11078     size = MAX_PATH;
11079     lstrcpyA(path, "kiwi");
11080     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11081     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11082     ok(!lstrcmpA(path, "kiwi"),
11083        "Expected path to be unchanged, got \"%s\"\n", path);
11084     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11085
11086     r = MsiDoAction(hpkg, "FileCost");
11087     ok(r == ERROR_SUCCESS, "file cost failed\n");
11088
11089     /* SourceDir after FileCost */
11090     size = MAX_PATH;
11091     lstrcpyA(path, "kiwi");
11092     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11094     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11095     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11096
11097     /* SOURCEDIR after FileCost */
11098     size = MAX_PATH;
11099     lstrcpyA(path, "kiwi");
11100     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11101     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11102     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11103     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11104
11105     /* SOURCEDIR source path still does not exist */
11106     size = MAX_PATH;
11107     lstrcpyA(path, "kiwi");
11108     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11109     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11110     ok(!lstrcmpA(path, "kiwi"),
11111        "Expected path to be unchanged, got \"%s\"\n", path);
11112     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11113
11114     r = MsiDoAction(hpkg, "CostFinalize");
11115     ok(r == ERROR_SUCCESS, "file cost failed\n");
11116
11117     /* SourceDir after CostFinalize */
11118     size = MAX_PATH;
11119     lstrcpyA(path, "kiwi");
11120     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11121     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11122     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11123     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11124
11125     /* SOURCEDIR after CostFinalize */
11126     size = MAX_PATH;
11127     lstrcpyA(path, "kiwi");
11128     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11130     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11131     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11132
11133     /* SOURCEDIR source path still does not exist */
11134     size = MAX_PATH;
11135     lstrcpyA(path, "kiwi");
11136     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11137     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11138     ok(!lstrcmpA(path, "kiwi"),
11139        "Expected path to be unchanged, got \"%s\"\n", path);
11140     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11141
11142     r = MsiDoAction(hpkg, "ResolveSource");
11143     ok(r == ERROR_SUCCESS, "file cost failed\n");
11144
11145     /* SourceDir after ResolveSource */
11146     size = MAX_PATH;
11147     lstrcpyA(path, "kiwi");
11148     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11149     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11150     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11151     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11152
11153     /* SOURCEDIR after ResolveSource */
11154     size = MAX_PATH;
11155     lstrcpyA(path, "kiwi");
11156     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11157     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11158     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11159     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11160
11161     /* SOURCEDIR source path still does not exist */
11162     size = MAX_PATH;
11163     lstrcpyA(path, "kiwi");
11164     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11165     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11166     ok(!lstrcmpA(path, "kiwi"),
11167        "Expected path to be unchanged, got \"%s\"\n", path);
11168     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11169
11170     MsiCloseHandle(hdb);
11171     MsiCloseHandle(hpkg);
11172     DeleteFileA(msifile);
11173 }
11174
11175 struct access_res
11176 {
11177     BOOL gothandle;
11178     DWORD lasterr;
11179     BOOL ignore;
11180 };
11181
11182 static const struct access_res create[16] =
11183 {
11184     { TRUE, ERROR_SUCCESS, TRUE },
11185     { TRUE, ERROR_SUCCESS, TRUE },
11186     { TRUE, ERROR_SUCCESS, FALSE },
11187     { TRUE, ERROR_SUCCESS, FALSE },
11188     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11189     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11190     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11191     { TRUE, ERROR_SUCCESS, FALSE },
11192     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11193     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11194     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11195     { TRUE, ERROR_SUCCESS, TRUE },
11196     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11197     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11198     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11199     { TRUE, ERROR_SUCCESS, TRUE }
11200 };
11201
11202 static const struct access_res create_commit[16] =
11203 {
11204     { TRUE, ERROR_SUCCESS, TRUE },
11205     { TRUE, ERROR_SUCCESS, TRUE },
11206     { TRUE, ERROR_SUCCESS, FALSE },
11207     { TRUE, ERROR_SUCCESS, FALSE },
11208     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11209     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11210     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11211     { TRUE, ERROR_SUCCESS, FALSE },
11212     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11213     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11214     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11215     { TRUE, ERROR_SUCCESS, TRUE },
11216     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11217     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11218     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11219     { TRUE, ERROR_SUCCESS, TRUE }
11220 };
11221
11222 static const struct access_res create_close[16] =
11223 {
11224     { TRUE, ERROR_SUCCESS, FALSE },
11225     { TRUE, ERROR_SUCCESS, FALSE },
11226     { TRUE, ERROR_SUCCESS, FALSE },
11227     { TRUE, ERROR_SUCCESS, FALSE },
11228     { TRUE, ERROR_SUCCESS, FALSE },
11229     { TRUE, ERROR_SUCCESS, FALSE },
11230     { TRUE, ERROR_SUCCESS, FALSE },
11231     { TRUE, ERROR_SUCCESS, FALSE },
11232     { TRUE, ERROR_SUCCESS, FALSE },
11233     { TRUE, ERROR_SUCCESS, FALSE },
11234     { TRUE, ERROR_SUCCESS, FALSE },
11235     { TRUE, ERROR_SUCCESS, FALSE },
11236     { TRUE, ERROR_SUCCESS, FALSE },
11237     { TRUE, ERROR_SUCCESS, FALSE },
11238     { TRUE, ERROR_SUCCESS, FALSE },
11239     { TRUE, ERROR_SUCCESS }
11240 };
11241
11242 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
11243 {
11244     DWORD access = 0, share = 0;
11245     DWORD lasterr;
11246     HANDLE hfile;
11247     int i, j, idx = 0;
11248
11249     for (i = 0; i < 4; i++)
11250     {
11251         if (i == 0) access = 0;
11252         if (i == 1) access = GENERIC_READ;
11253         if (i == 2) access = GENERIC_WRITE;
11254         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
11255
11256         for (j = 0; j < 4; j++)
11257         {
11258             if (ares[idx].ignore)
11259                 continue;
11260
11261             if (j == 0) share = 0;
11262             if (j == 1) share = FILE_SHARE_READ;
11263             if (j == 2) share = FILE_SHARE_WRITE;
11264             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
11265
11266             SetLastError(0xdeadbeef);
11267             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
11268                                 FILE_ATTRIBUTE_NORMAL, 0);
11269             lasterr = GetLastError();
11270
11271             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
11272                "(%d, handle, %d): Expected %d, got %d\n",
11273                line, idx, ares[idx].gothandle,
11274                (hfile != INVALID_HANDLE_VALUE));
11275
11276             ok(lasterr == ares[idx].lasterr ||
11277                lasterr == 0xdeadbeef, /* win9x */
11278                "(%d, lasterr, %d): Expected %d, got %d\n",
11279                line, idx, ares[idx].lasterr, lasterr);
11280
11281             CloseHandle(hfile);
11282             idx++;
11283         }
11284     }
11285 }
11286
11287 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
11288
11289 static void test_access(void)
11290 {
11291     MSIHANDLE hdb;
11292     UINT r;
11293
11294     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
11295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11296
11297     test_file_access(msifile, create);
11298
11299     r = MsiDatabaseCommit(hdb);
11300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11301
11302     test_file_access(msifile, create_commit);
11303
11304     MsiCloseHandle(hdb);
11305
11306     test_file_access(msifile, create_close);
11307
11308     DeleteFileA(msifile);
11309
11310     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
11311     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11312
11313     test_file_access(msifile, create);
11314
11315     r = MsiDatabaseCommit(hdb);
11316     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11317
11318     test_file_access(msifile, create_commit);
11319
11320     MsiCloseHandle(hdb);
11321
11322     test_file_access(msifile, create_close);
11323
11324     DeleteFileA(msifile);
11325 }
11326
11327 static void test_emptypackage(void)
11328 {
11329     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
11330     MSIHANDLE hview = 0, hrec = 0;
11331     MSICONDITION condition;
11332     CHAR buffer[MAX_PATH];
11333     DWORD size;
11334     UINT r;
11335
11336     r = MsiOpenPackageA("", &hpkg);
11337     todo_wine
11338     {
11339         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11340     }
11341
11342     hdb = MsiGetActiveDatabase(hpkg);
11343     todo_wine
11344     {
11345         ok(hdb != 0, "Expected a valid database handle\n");
11346     }
11347
11348     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
11349     todo_wine
11350     {
11351         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11352     }
11353     r = MsiViewExecute(hview, 0);
11354     todo_wine
11355     {
11356         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11357     }
11358
11359     r = MsiViewFetch(hview, &hrec);
11360     todo_wine
11361     {
11362         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11363     }
11364
11365     size = MAX_PATH;
11366     r = MsiRecordGetString(hrec, 1, buffer, &size);
11367     todo_wine
11368     {
11369         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11370         ok(!lstrcmpA(buffer, "_Property"),
11371            "Expected \"_Property\", got \"%s\"\n", buffer);
11372     }
11373
11374     MsiCloseHandle(hrec);
11375
11376     r = MsiViewFetch(hview, &hrec);
11377     todo_wine
11378     {
11379         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11380     }
11381
11382     size = MAX_PATH;
11383     r = MsiRecordGetString(hrec, 1, buffer, &size);
11384     todo_wine
11385     {
11386         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11387         ok(!lstrcmpA(buffer, "#_FolderCache"),
11388            "Expected \"_Property\", got \"%s\"\n", buffer);
11389     }
11390
11391     MsiCloseHandle(hrec);
11392     MsiViewClose(hview);
11393     MsiCloseHandle(hview);
11394
11395     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
11396     todo_wine
11397     {
11398         ok(condition == MSICONDITION_FALSE,
11399            "Expected MSICONDITION_FALSE, got %d\n", condition);
11400     }
11401
11402     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
11403     todo_wine
11404     {
11405         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11406     }
11407     r = MsiViewExecute(hview, 0);
11408     todo_wine
11409     {
11410         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11411     }
11412
11413     /* _Property table is not empty */
11414     r = MsiViewFetch(hview, &hrec);
11415     todo_wine
11416     {
11417         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11418     }
11419
11420     MsiCloseHandle(hrec);
11421     MsiViewClose(hview);
11422     MsiCloseHandle(hview);
11423
11424     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
11425     todo_wine
11426     {
11427         ok(condition == MSICONDITION_FALSE,
11428            "Expected MSICONDITION_FALSE, got %d\n", condition);
11429     }
11430
11431     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
11432     todo_wine
11433     {
11434         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11435     }
11436     r = MsiViewExecute(hview, 0);
11437     todo_wine
11438     {
11439         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11440     }
11441
11442     /* #_FolderCache is not empty */
11443     r = MsiViewFetch(hview, &hrec);
11444     todo_wine
11445     {
11446         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11447     }
11448
11449     MsiCloseHandle(hrec);
11450     MsiViewClose(hview);
11451     MsiCloseHandle(hview);
11452
11453     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
11454     todo_wine
11455     {
11456         ok(r == ERROR_BAD_QUERY_SYNTAX,
11457            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11458     }
11459
11460     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
11461     todo_wine
11462     {
11463         ok(r == ERROR_BAD_QUERY_SYNTAX,
11464            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11465     }
11466
11467     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
11468     todo_wine
11469     {
11470         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
11471            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
11472     }
11473
11474     MsiCloseHandle(hsuminfo);
11475
11476     r = MsiDatabaseCommit(hdb);
11477     todo_wine
11478     {
11479         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11480     }
11481
11482     MsiCloseHandle(hdb);
11483     MsiCloseHandle(hpkg);
11484 }
11485
11486 static void test_MsiGetProductProperty(void)
11487 {
11488     MSIHANDLE hprod, hdb;
11489     CHAR val[MAX_PATH];
11490     CHAR path[MAX_PATH];
11491     CHAR query[MAX_PATH];
11492     CHAR keypath[MAX_PATH*2];
11493     CHAR prodcode[MAX_PATH];
11494     CHAR prod_squashed[MAX_PATH];
11495     HKEY prodkey, userkey, props;
11496     DWORD size;
11497     LONG res;
11498     UINT r;
11499     SC_HANDLE scm;
11500
11501     scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
11502     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
11503     {
11504         win_skip("Different registry keys on Win9x and WinMe\n");
11505         return;
11506     }
11507     CloseServiceHandle(scm);
11508
11509     GetCurrentDirectoryA(MAX_PATH, path);
11510     lstrcatA(path, "\\");
11511
11512     create_test_guid(prodcode, prod_squashed);
11513
11514     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
11515     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11516
11517     r = MsiDatabaseCommit(hdb);
11518     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11519
11520     r = set_summary_info(hdb);
11521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11522
11523     r = run_query(hdb,
11524             "CREATE TABLE `Directory` ( "
11525             "`Directory` CHAR(255) NOT NULL, "
11526             "`Directory_Parent` CHAR(255), "
11527             "`DefaultDir` CHAR(255) NOT NULL "
11528             "PRIMARY KEY `Directory`)");
11529     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11530
11531     r = run_query(hdb,
11532             "CREATE TABLE `Property` ( "
11533             "`Property` CHAR(72) NOT NULL, "
11534             "`Value` CHAR(255) "
11535             "PRIMARY KEY `Property`)");
11536     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11537
11538     sprintf(query, "INSERT INTO `Property` "
11539             "(`Property`, `Value`) "
11540             "VALUES( 'ProductCode', '%s' )", prodcode);
11541     r = run_query(hdb, query);
11542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11543
11544     r = MsiDatabaseCommit(hdb);
11545     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11546
11547     MsiCloseHandle(hdb);
11548
11549     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
11550     lstrcatA(keypath, prod_squashed);
11551
11552     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
11553     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11554
11555     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11556     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
11557     lstrcatA(keypath, prod_squashed);
11558
11559     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
11560     if (res == ERROR_ACCESS_DENIED)
11561     {
11562         skip("Not enough rights to perform tests\n");
11563         RegDeleteKeyA(prodkey, "");
11564         RegCloseKey(prodkey);
11565         return;
11566     }
11567     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11568
11569     res = RegCreateKeyA(userkey, "InstallProperties", &props);
11570     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11571
11572     lstrcpyA(val, path);
11573     lstrcatA(val, "\\winetest.msi");
11574     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
11575                          (const BYTE *)val, lstrlenA(val) + 1);
11576     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11577
11578     hprod = 0xdeadbeef;
11579     r = MsiOpenProductA(prodcode, &hprod);
11580     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11581     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
11582
11583     /* hProduct is invalid */
11584     size = MAX_PATH;
11585     lstrcpyA(val, "apple");
11586     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
11587     ok(r == ERROR_INVALID_HANDLE,
11588        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11589     ok(!lstrcmpA(val, "apple"),
11590        "Expected val to be unchanged, got \"%s\"\n", val);
11591     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11592
11593     /* szProperty is NULL */
11594     size = MAX_PATH;
11595     lstrcpyA(val, "apple");
11596     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
11597     ok(r == ERROR_INVALID_PARAMETER,
11598        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11599     ok(!lstrcmpA(val, "apple"),
11600        "Expected val to be unchanged, got \"%s\"\n", val);
11601     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11602
11603     /* szProperty is empty */
11604     size = MAX_PATH;
11605     lstrcpyA(val, "apple");
11606     r = MsiGetProductPropertyA(hprod, "", val, &size);
11607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11608     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11609     ok(size == 0, "Expected 0, got %d\n", size);
11610
11611     /* get the property */
11612     size = MAX_PATH;
11613     lstrcpyA(val, "apple");
11614     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11615     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11616     ok(!lstrcmpA(val, prodcode),
11617        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11618     ok(size == lstrlenA(prodcode),
11619        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11620
11621     /* lpValueBuf is NULL */
11622     size = MAX_PATH;
11623     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
11624     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11625     ok(size == lstrlenA(prodcode),
11626        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11627
11628     /* pcchValueBuf is NULL */
11629     lstrcpyA(val, "apple");
11630     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
11631     ok(r == ERROR_INVALID_PARAMETER,
11632        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11633     ok(!lstrcmpA(val, "apple"),
11634        "Expected val to be unchanged, got \"%s\"\n", val);
11635     ok(size == lstrlenA(prodcode),
11636        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11637
11638     /* pcchValueBuf is too small */
11639     size = 4;
11640     lstrcpyA(val, "apple");
11641     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11642     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11643     ok(!strncmp(val, prodcode, 3),
11644        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
11645     ok(size == lstrlenA(prodcode),
11646        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11647
11648     /* pcchValueBuf does not leave room for NULL terminator */
11649     size = lstrlenA(prodcode);
11650     lstrcpyA(val, "apple");
11651     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11652     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11653     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
11654        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
11655     ok(size == lstrlenA(prodcode),
11656        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11657
11658     /* pcchValueBuf has enough room for NULL terminator */
11659     size = lstrlenA(prodcode) + 1;
11660     lstrcpyA(val, "apple");
11661     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11662     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11663     ok(!lstrcmpA(val, prodcode),
11664        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11665     ok(size == lstrlenA(prodcode),
11666        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11667
11668     /* nonexistent property */
11669     size = MAX_PATH;
11670     lstrcpyA(val, "apple");
11671     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
11672     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11673     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11674     ok(size == 0, "Expected 0, got %d\n", size);
11675
11676     r = MsiSetPropertyA(hprod, "NewProperty", "value");
11677     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11678
11679     /* non-product property set */
11680     size = MAX_PATH;
11681     lstrcpyA(val, "apple");
11682     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
11683     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11684     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11685     ok(size == 0, "Expected 0, got %d\n", size);
11686
11687     r = MsiSetPropertyA(hprod, "ProductCode", "value");
11688     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11689
11690     /* non-product property that is also a product property set */
11691     size = MAX_PATH;
11692     lstrcpyA(val, "apple");
11693     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11695     ok(!lstrcmpA(val, prodcode),
11696        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11697     ok(size == lstrlenA(prodcode),
11698        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11699
11700     MsiCloseHandle(hprod);
11701
11702     RegDeleteValueA(props, "LocalPackage");
11703     RegDeleteKeyA(props, "");
11704     RegCloseKey(props);
11705     RegDeleteKeyA(userkey, "");
11706     RegCloseKey(userkey);
11707     RegDeleteKeyA(prodkey, "");
11708     RegCloseKey(prodkey);
11709     DeleteFileA(msifile);
11710 }
11711
11712 static void test_MsiSetProperty(void)
11713 {
11714     MSIHANDLE hpkg, hdb, hrec;
11715     CHAR buf[MAX_PATH];
11716     LPCSTR query;
11717     DWORD size;
11718     UINT r;
11719
11720     hpkg = package_from_db(create_package_db());
11721     ok(hpkg != 0, "Expected a valid package\n");
11722
11723     /* invalid hInstall */
11724     r = MsiSetPropertyA(0, "Prop", "Val");
11725     ok(r == ERROR_INVALID_HANDLE,
11726        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11727
11728     /* invalid hInstall */
11729     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
11730     ok(r == ERROR_INVALID_HANDLE,
11731        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11732
11733     /* szName is NULL */
11734     r = MsiSetPropertyA(hpkg, NULL, "Val");
11735     ok(r == ERROR_INVALID_PARAMETER,
11736        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11737
11738     /* both szName and szValue are NULL */
11739     r = MsiSetPropertyA(hpkg, NULL, NULL);
11740     ok(r == ERROR_INVALID_PARAMETER,
11741        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11742
11743     /* szName is empty */
11744     r = MsiSetPropertyA(hpkg, "", "Val");
11745     ok(r == ERROR_FUNCTION_FAILED,
11746        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
11747
11748     /* szName is empty and szValue is NULL */
11749     r = MsiSetPropertyA(hpkg, "", NULL);
11750     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11751
11752     /* set a property */
11753     r = MsiSetPropertyA(hpkg, "Prop", "Val");
11754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11755
11756     /* get the property */
11757     size = MAX_PATH;
11758     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11759     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11760     ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
11761     ok(size == 3, "Expected 3, got %d\n", size);
11762
11763     /* update the property */
11764     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
11765     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11766
11767     /* get the property */
11768     size = MAX_PATH;
11769     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11770     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11771     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
11772     ok(size == 4, "Expected 4, got %d\n", size);
11773
11774     hdb = MsiGetActiveDatabase(hpkg);
11775     ok(hdb != 0, "Expected a valid database handle\n");
11776
11777     /* set prop is not in the _Property table */
11778     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
11779     r = do_query(hdb, query, &hrec);
11780     ok(r == ERROR_BAD_QUERY_SYNTAX,
11781        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11782
11783     /* set prop is not in the Property table */
11784     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
11785     r = do_query(hdb, query, &hrec);
11786     ok(r == ERROR_BAD_QUERY_SYNTAX,
11787        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11788
11789     MsiCloseHandle(hdb);
11790
11791     /* szValue is an empty string */
11792     r = MsiSetPropertyA(hpkg, "Prop", "");
11793     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11794
11795     /* try to get the property */
11796     size = MAX_PATH;
11797     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11798     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11799     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
11800     ok(size == 0, "Expected 0, got %d\n", size);
11801
11802     /* reset the property */
11803     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
11804     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11805
11806     /* delete the property */
11807     r = MsiSetPropertyA(hpkg, "Prop", NULL);
11808     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11809
11810     /* try to get the property */
11811     size = MAX_PATH;
11812     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11813     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11814     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
11815     ok(size == 0, "Expected 0, got %d\n", size);
11816
11817     MsiCloseHandle(hpkg);
11818     DeleteFileA(msifile);
11819 }
11820
11821 static void test_MsiApplyMultiplePatches(void)
11822 {
11823     UINT r, type = GetDriveType(NULL);
11824
11825     if (!pMsiApplyMultiplePatchesA) {
11826         win_skip("MsiApplyMultiplePatchesA not found\n");
11827         return;
11828     }
11829
11830     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
11831     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11832
11833     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
11834     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11835
11836     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
11837     todo_wine
11838     {
11839         if (type == DRIVE_FIXED)
11840             ok(r == ERROR_PATH_NOT_FOUND,
11841                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
11842         else
11843             ok(r == ERROR_INVALID_NAME,
11844                "Expected ERROR_INVALID_NAME, got %u\n", r);
11845     }
11846
11847     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
11848     todo_wine
11849     {
11850         if (type == DRIVE_FIXED)
11851             ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED,
11852                "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
11853         else
11854             ok(r == ERROR_INVALID_NAME,
11855                "Expected ERROR_INVALID_NAME, got %u\n", r);
11856     }
11857
11858     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
11859     todo_wine
11860     {
11861         if (type == DRIVE_FIXED)
11862             ok(r == ERROR_PATH_NOT_FOUND,
11863                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
11864         else
11865             ok(r == ERROR_INVALID_NAME,
11866                "Expected ERROR_INVALID_NAME, got %u\n", r);
11867     }
11868
11869     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
11870     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
11871
11872     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
11873     todo_wine
11874     {
11875         if (type == DRIVE_FIXED)
11876             ok(r == ERROR_PATH_NOT_FOUND,
11877                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
11878         else
11879             ok(r == ERROR_INVALID_NAME,
11880                "Expected ERROR_INVALID_NAME, got %u\n", r);
11881     }
11882
11883     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
11884     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
11885
11886     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
11887     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
11888 }
11889
11890 static void test_MsiApplyPatch(void)
11891 {
11892     UINT r;
11893
11894     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
11895     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11896
11897     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
11898     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11899 }
11900
11901 START_TEST(package)
11902 {
11903     STATEMGRSTATUS status;
11904     BOOL ret = FALSE;
11905
11906     init_functionpointers();
11907
11908     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
11909
11910     /* Create a restore point ourselves so we circumvent the multitude of restore points
11911      * that would have been created by all the installation and removal tests.
11912      */
11913     if (pSRSetRestorePointA)
11914     {
11915         memset(&status, 0, sizeof(status));
11916         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
11917     }
11918
11919     test_createpackage();
11920     test_doaction();
11921     test_gettargetpath_bad();
11922     test_settargetpath();
11923     test_props();
11924     test_property_table();
11925     test_condition();
11926     test_msipackage();
11927     test_formatrecord2();
11928     test_states();
11929     test_getproperty();
11930     test_removefiles();
11931     test_appsearch();
11932     test_appsearch_complocator();
11933     test_appsearch_reglocator();
11934     test_appsearch_inilocator();
11935     test_appsearch_drlocator();
11936     test_featureparents();
11937     test_installprops();
11938     test_launchconditions();
11939     test_ccpsearch();
11940     test_complocator();
11941     test_MsiGetSourcePath();
11942     test_shortlongsource();
11943     test_sourcedir();
11944     test_access();
11945     test_emptypackage();
11946     test_MsiGetProductProperty();
11947     test_MsiSetProperty();
11948     test_MsiApplyMultiplePatches();
11949     test_MsiApplyPatch();
11950
11951     if (pSRSetRestorePointA && ret)
11952     {
11953         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
11954         if (ret)
11955             remove_restore_point(status.llSequenceNumber);
11956     }
11957 }