crypt32: Make sure we show Unicode characters (Dutch translation).
[wine] / dlls / msi / tests / package.c
1 /*
2  * tests for Microsoft Installer functionality
3  *
4  * Copyright 2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #define COBJMACROS
23
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29
30 #include "wine/test.h"
31
32 static const char msifile[] = "winetest.msi";
33 char CURR_DIR[MAX_PATH];
34
35 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
36
37 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
38
39 static void init_functionpointers(void)
40 {
41     HMODULE hmsi = GetModuleHandleA("msi.dll");
42     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
43
44 #define GET_PROC(mod, func) \
45     p ## func = (void*)GetProcAddress(mod, #func);
46
47     GET_PROC(hmsi, MsiApplyMultiplePatchesA);
48
49     GET_PROC(hadvapi32, ConvertSidToStringSidA);
50
51 #undef GET_PROC
52 }
53
54
55 static LPSTR get_user_sid(LPSTR *usersid)
56 {
57     HANDLE token;
58     BYTE buf[1024];
59     DWORD size;
60     PTOKEN_USER user;
61
62     if (!pConvertSidToStringSidA)
63     {
64         win_skip("ConvertSidToStringSidA is not available\n");
65         return NULL;
66     }
67
68     *usersid = NULL;
69     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
70     size = sizeof(buf);
71     GetTokenInformation(token, TokenUser, buf, size, &size);
72     user = (PTOKEN_USER)buf;
73     pConvertSidToStringSidA(user->User.Sid, usersid);
74     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
75     CloseHandle(token);
76     return *usersid;
77 }
78
79 /* RegDeleteTreeW from dlls/advapi32/registry.c */
80 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
81 {
82     LONG ret;
83     DWORD dwMaxSubkeyLen, dwMaxValueLen;
84     DWORD dwMaxLen, dwSize;
85     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
86     HKEY hSubKey = hKey;
87
88     if(lpszSubKey)
89     {
90         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
91         if (ret) return ret;
92     }
93
94     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
95             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
96     if (ret) goto cleanup;
97
98     dwMaxSubkeyLen++;
99     dwMaxValueLen++;
100     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
101     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
102     {
103         /* Name too big: alloc a buffer for it */
104         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
105         {
106             ret = ERROR_NOT_ENOUGH_MEMORY;
107             goto cleanup;
108         }
109     }
110
111     /* Recursively delete all the subkeys */
112     while (TRUE)
113     {
114         dwSize = dwMaxLen;
115         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
116                           NULL, NULL, NULL)) break;
117
118         ret = package_RegDeleteTreeW(hSubKey, lpszName);
119         if (ret) goto cleanup;
120     }
121
122     if (lpszSubKey)
123         ret = RegDeleteKeyW(hKey, lpszSubKey);
124     else
125         while (TRUE)
126         {
127             dwSize = dwMaxLen;
128             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
129                   NULL, NULL, NULL, NULL)) break;
130
131             ret = RegDeleteValueW(hKey, lpszName);
132             if (ret) goto cleanup;
133         }
134
135 cleanup:
136     if (lpszName != szNameBuf)
137         HeapFree(GetProcessHeap(), 0, lpszName);
138     if(lpszSubKey)
139         RegCloseKey(hSubKey);
140     return ret;
141 }
142
143 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
144 {
145     DWORD i,n=1;
146     GUID guid;
147
148     if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
149         return FALSE;
150
151     for(i=0; i<8; i++)
152         out[7-i] = in[n++];
153     n++;
154     for(i=0; i<4; i++)
155         out[11-i] = in[n++];
156     n++;
157     for(i=0; i<4; i++)
158         out[15-i] = in[n++];
159     n++;
160     for(i=0; i<2; i++)
161     {
162         out[17+i*2] = in[n++];
163         out[16+i*2] = in[n++];
164     }
165     n++;
166     for( ; i<8; i++)
167     {
168         out[17+i*2] = in[n++];
169         out[16+i*2] = in[n++];
170     }
171     out[32]=0;
172     return TRUE;
173 }
174
175 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
176 {
177     WCHAR guidW[MAX_PATH];
178     WCHAR squashedW[MAX_PATH];
179     GUID guid;
180     HRESULT hr;
181     int size;
182
183     hr = CoCreateGuid(&guid);
184     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
185
186     size = StringFromGUID2(&guid, guidW, MAX_PATH);
187     ok(size == 39, "Expected 39, got %d\n", hr);
188
189     WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
190     squash_guid(guidW, squashedW);
191     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
192 }
193
194 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
195                                LPCSTR guid, LPSTR usersid, BOOL dir)
196 {
197     WCHAR guidW[MAX_PATH];
198     WCHAR squashedW[MAX_PATH];
199     CHAR squashed[MAX_PATH];
200     CHAR comppath[MAX_PATH];
201     CHAR prodpath[MAX_PATH];
202     CHAR path[MAX_PATH];
203     LPCSTR prod = NULL;
204     HKEY hkey;
205
206     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
207     squash_guid(guidW, squashedW);
208     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
209
210     if (context == MSIINSTALLCONTEXT_MACHINE)
211     {
212         prod = "3D0DAE300FACA1300AD792060BCDAA92";
213         sprintf(comppath,
214                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
215                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
216         lstrcpyA(prodpath,
217                  "SOFTWARE\\Classes\\Installer\\"
218                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
219     }
220     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
221     {
222         prod = "7D2F387510109040002000060BECB6AB";
223         sprintf(comppath,
224                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
225                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
226         sprintf(prodpath,
227                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
228                 "Installer\\%s\\Installer\\Products\\"
229                 "7D2F387510109040002000060BECB6AB", usersid);
230     }
231     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
232     {
233         prod = "7D2F387510109040002000060BECB6AB";
234         sprintf(comppath,
235                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
236                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
237         sprintf(prodpath,
238                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
239                 "Installer\\Managed\\%s\\Installer\\Products\\"
240                 "7D2F387510109040002000060BECB6AB", usersid);
241     }
242
243     RegCreateKeyA(HKEY_LOCAL_MACHINE, comppath, &hkey);
244
245     lstrcpyA(path, CURR_DIR);
246     lstrcatA(path, "\\");
247     if (!dir) lstrcatA(path, filename);
248
249     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
250     RegCloseKey(hkey);
251
252     RegCreateKeyA(HKEY_LOCAL_MACHINE, prodpath, &hkey);
253     RegCloseKey(hkey);
254 }
255
256 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
257 {
258     WCHAR guidW[MAX_PATH];
259     WCHAR squashedW[MAX_PATH];
260     WCHAR substrW[MAX_PATH];
261     CHAR squashed[MAX_PATH];
262     CHAR comppath[MAX_PATH];
263     CHAR prodpath[MAX_PATH];
264
265     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
266     squash_guid(guidW, squashedW);
267     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
268
269     if (context == MSIINSTALLCONTEXT_MACHINE)
270     {
271         sprintf(comppath,
272                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
273                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
274         lstrcpyA(prodpath,
275                  "SOFTWARE\\Classes\\Installer\\"
276                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
277     }
278     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
279     {
280         sprintf(comppath,
281                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
282                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
283         sprintf(prodpath,
284                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
285                 "Installer\\%s\\Installer\\Products\\"
286                 "7D2F387510109040002000060BECB6AB", usersid);
287     }
288     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
289     {
290         sprintf(comppath,
291                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
292                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
293         sprintf(prodpath,
294                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
295                 "Installer\\Managed\\%s\\Installer\\Products\\"
296                 "7D2F387510109040002000060BECB6AB", usersid);
297     }
298
299     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
300     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
301
302     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
303     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
304 }
305
306 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
307 {
308     MSIHANDLE hview = 0;
309     UINT r, ret;
310
311     /* open a select query */
312     r = MsiDatabaseOpenView(hdb, query, &hview);
313     if (r != ERROR_SUCCESS)
314         return r;
315     r = MsiViewExecute(hview, 0);
316     if (r != ERROR_SUCCESS)
317         return r;
318     ret = MsiViewFetch(hview, phrec);
319     r = MsiViewClose(hview);
320     if (r != ERROR_SUCCESS)
321         return r;
322     r = MsiCloseHandle(hview);
323     if (r != ERROR_SUCCESS)
324         return r;
325     return ret;
326 }
327
328 static UINT run_query( MSIHANDLE hdb, const char *query )
329 {
330     MSIHANDLE hview = 0;
331     UINT r;
332
333     r = MsiDatabaseOpenView(hdb, query, &hview);
334     if( r != ERROR_SUCCESS )
335         return r;
336
337     r = MsiViewExecute(hview, 0);
338     if( r == ERROR_SUCCESS )
339         r = MsiViewClose(hview);
340     MsiCloseHandle(hview);
341     return r;
342 }
343
344 static UINT create_component_table( MSIHANDLE hdb )
345 {
346     return run_query( hdb,
347             "CREATE TABLE `Component` ( "
348             "`Component` CHAR(72) NOT NULL, "
349             "`ComponentId` CHAR(38), "
350             "`Directory_` CHAR(72) NOT NULL, "
351             "`Attributes` SHORT NOT NULL, "
352             "`Condition` CHAR(255), "
353             "`KeyPath` CHAR(72) "
354             "PRIMARY KEY `Component`)" );
355 }
356
357 static UINT create_feature_table( MSIHANDLE hdb )
358 {
359     return run_query( hdb,
360             "CREATE TABLE `Feature` ( "
361             "`Feature` CHAR(38) NOT NULL, "
362             "`Feature_Parent` CHAR(38), "
363             "`Title` CHAR(64), "
364             "`Description` CHAR(255), "
365             "`Display` SHORT NOT NULL, "
366             "`Level` SHORT NOT NULL, "
367             "`Directory_` CHAR(72), "
368             "`Attributes` SHORT NOT NULL "
369             "PRIMARY KEY `Feature`)" );
370 }
371
372 static UINT create_feature_components_table( MSIHANDLE hdb )
373 {
374     return run_query( hdb,
375             "CREATE TABLE `FeatureComponents` ( "
376             "`Feature_` CHAR(38) NOT NULL, "
377             "`Component_` CHAR(72) NOT NULL "
378             "PRIMARY KEY `Feature_`, `Component_` )" );
379 }
380
381 static UINT create_file_table( MSIHANDLE hdb )
382 {
383     return run_query( hdb,
384             "CREATE TABLE `File` ("
385             "`File` CHAR(72) NOT NULL, "
386             "`Component_` CHAR(72) NOT NULL, "
387             "`FileName` CHAR(255) NOT NULL, "
388             "`FileSize` LONG NOT NULL, "
389             "`Version` CHAR(72), "
390             "`Language` CHAR(20), "
391             "`Attributes` SHORT, "
392             "`Sequence` SHORT NOT NULL "
393             "PRIMARY KEY `File`)" );
394 }
395
396 static UINT create_remove_file_table( MSIHANDLE hdb )
397 {
398     return run_query( hdb,
399             "CREATE TABLE `RemoveFile` ("
400             "`FileKey` CHAR(72) NOT NULL, "
401             "`Component_` CHAR(72) NOT NULL, "
402             "`FileName` CHAR(255) LOCALIZABLE, "
403             "`DirProperty` CHAR(72) NOT NULL, "
404             "`InstallMode` SHORT NOT NULL "
405             "PRIMARY KEY `FileKey`)" );
406 }
407
408 static UINT create_appsearch_table( MSIHANDLE hdb )
409 {
410     return run_query( hdb,
411             "CREATE TABLE `AppSearch` ("
412             "`Property` CHAR(72) NOT NULL, "
413             "`Signature_` CHAR(72) NOT NULL "
414             "PRIMARY KEY `Property`, `Signature_`)" );
415 }
416
417 static UINT create_reglocator_table( MSIHANDLE hdb )
418 {
419     return run_query( hdb,
420             "CREATE TABLE `RegLocator` ("
421             "`Signature_` CHAR(72) NOT NULL, "
422             "`Root` SHORT NOT NULL, "
423             "`Key` CHAR(255) NOT NULL, "
424             "`Name` CHAR(255), "
425             "`Type` SHORT "
426             "PRIMARY KEY `Signature_`)" );
427 }
428
429 static UINT create_signature_table( MSIHANDLE hdb )
430 {
431     return run_query( hdb,
432             "CREATE TABLE `Signature` ("
433             "`Signature` CHAR(72) NOT NULL, "
434             "`FileName` CHAR(255) NOT NULL, "
435             "`MinVersion` CHAR(20), "
436             "`MaxVersion` CHAR(20), "
437             "`MinSize` LONG, "
438             "`MaxSize` LONG, "
439             "`MinDate` LONG, "
440             "`MaxDate` LONG, "
441             "`Languages` CHAR(255) "
442             "PRIMARY KEY `Signature`)" );
443 }
444
445 static UINT create_launchcondition_table( MSIHANDLE hdb )
446 {
447     return run_query( hdb,
448             "CREATE TABLE `LaunchCondition` ("
449             "`Condition` CHAR(255) NOT NULL, "
450             "`Description` CHAR(255) NOT NULL "
451             "PRIMARY KEY `Condition`)" );
452 }
453
454 static UINT create_property_table( MSIHANDLE hdb )
455 {
456     return run_query( hdb,
457             "CREATE TABLE `Property` ("
458             "`Property` CHAR(72) NOT NULL, "
459             "`Value` CHAR(0) "
460             "PRIMARY KEY `Property`)" );
461 }
462
463 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
464 {
465     return run_query( hdb,
466             "CREATE TABLE `InstallExecuteSequence` ("
467             "`Action` CHAR(72) NOT NULL, "
468             "`Condition` CHAR(255), "
469             "`Sequence` SHORT "
470             "PRIMARY KEY `Action`)" );
471 }
472
473 static UINT create_media_table( MSIHANDLE hdb )
474 {
475     return run_query( hdb,
476             "CREATE TABLE `Media` ("
477             "`DiskId` SHORT NOT NULL, "
478             "`LastSequence` SHORT NOT NULL, "
479             "`DiskPrompt` CHAR(64), "
480             "`Cabinet` CHAR(255), "
481             "`VolumeLabel` CHAR(32), "
482             "`Source` CHAR(72) "
483             "PRIMARY KEY `DiskId`)" );
484 }
485
486 static UINT create_ccpsearch_table( MSIHANDLE hdb )
487 {
488     return run_query( hdb,
489             "CREATE TABLE `CCPSearch` ("
490             "`Signature_` CHAR(72) NOT NULL "
491             "PRIMARY KEY `Signature_`)" );
492 }
493
494 static UINT create_drlocator_table( MSIHANDLE hdb )
495 {
496     return run_query( hdb,
497             "CREATE TABLE `DrLocator` ("
498             "`Signature_` CHAR(72) NOT NULL, "
499             "`Parent` CHAR(72), "
500             "`Path` CHAR(255), "
501             "`Depth` SHORT "
502             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
503 }
504
505 static UINT create_complocator_table( MSIHANDLE hdb )
506 {
507     return run_query( hdb,
508             "CREATE TABLE `CompLocator` ("
509             "`Signature_` CHAR(72) NOT NULL, "
510             "`ComponentId` CHAR(38) NOT NULL, "
511             "`Type` SHORT "
512             "PRIMARY KEY `Signature_`)" );
513 }
514
515 static UINT create_inilocator_table( MSIHANDLE hdb )
516 {
517     return run_query( hdb,
518             "CREATE TABLE `IniLocator` ("
519             "`Signature_` CHAR(72) NOT NULL, "
520             "`FileName` CHAR(255) NOT NULL, "
521             "`Section` CHAR(96)NOT NULL, "
522             "`Key` CHAR(128)NOT NULL, "
523             "`Field` SHORT, "
524             "`Type` SHORT "
525             "PRIMARY KEY `Signature_`)" );
526 }
527
528 #define make_add_entry(type, qtext) \
529     static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
530     { \
531         char insert[] = qtext; \
532         char *query; \
533         UINT sz, r; \
534         sz = strlen(values) + sizeof insert; \
535         query = HeapAlloc(GetProcessHeap(),0,sz); \
536         sprintf(query,insert,values); \
537         r = run_query( hdb, query ); \
538         HeapFree(GetProcessHeap(), 0, query); \
539         return r; \
540     }
541
542 make_add_entry(component,
543                "INSERT INTO `Component`  "
544                "(`Component`, `ComponentId`, `Directory_`, "
545                "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
546
547 make_add_entry(directory,
548                "INSERT INTO `Directory` "
549                "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
550
551 make_add_entry(feature,
552                "INSERT INTO `Feature` "
553                "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
554                "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
555
556 make_add_entry(feature_components,
557                "INSERT INTO `FeatureComponents` "
558                "(`Feature_`, `Component_`) VALUES( %s )")
559
560 make_add_entry(file,
561                "INSERT INTO `File` "
562                "(`File`, `Component_`, `FileName`, `FileSize`, "
563                "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
564
565 make_add_entry(appsearch,
566                "INSERT INTO `AppSearch` "
567                "(`Property`, `Signature_`) VALUES( %s )")
568
569 make_add_entry(reglocator,
570                "INSERT INTO `RegLocator` "
571                "(`Signature_`, `Root`, `Key`, `Name`, `Type`) VALUES( %s )")
572
573 make_add_entry(signature,
574                "INSERT INTO `Signature` "
575                "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
576                " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
577                "VALUES( %s )")
578
579 make_add_entry(launchcondition,
580                "INSERT INTO `LaunchCondition` "
581                "(`Condition`, `Description`) VALUES( %s )")
582
583 make_add_entry(property,
584                "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
585
586 make_add_entry(install_execute_sequence,
587                "INSERT INTO `InstallExecuteSequence` "
588                "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
589
590 make_add_entry(media,
591                "INSERT INTO `Media` "
592                "(`DiskId`, `LastSequence`, `DiskPrompt`, "
593                "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
594
595 make_add_entry(ccpsearch,
596                "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
597
598 make_add_entry(drlocator,
599                "INSERT INTO `DrLocator` "
600                "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
601
602 make_add_entry(complocator,
603                "INSERT INTO `CompLocator` "
604                "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
605
606 make_add_entry(inilocator,
607                "INSERT INTO `IniLocator` "
608                "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
609                "VALUES( %s )")
610
611 static UINT set_summary_info(MSIHANDLE hdb)
612 {
613     UINT res;
614     MSIHANDLE suminfo;
615
616     /* build summary info */
617     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
618     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
619
620     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
621                         "Installation Database");
622     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
623
624     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
625                         "Installation Database");
626     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
627
628     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
629                         "Wine Hackers");
630     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
631
632     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
633                     ";1033");
634     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
635
636     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
637                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
638     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
639
640     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
641     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
642
643     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
644     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
645
646     res = MsiSummaryInfoPersist(suminfo);
647     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
648
649     res = MsiCloseHandle( suminfo);
650     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
651
652     return res;
653 }
654
655
656 static MSIHANDLE create_package_db(void)
657 {
658     MSIHANDLE hdb = 0;
659     UINT res;
660
661     DeleteFile(msifile);
662
663     /* create an empty database */
664     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
665     ok( res == ERROR_SUCCESS , "Failed to create database\n" );
666     if( res != ERROR_SUCCESS )
667         return hdb;
668
669     res = MsiDatabaseCommit( hdb );
670     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
671
672     res = set_summary_info(hdb);
673
674     res = run_query( hdb,
675             "CREATE TABLE `Directory` ( "
676             "`Directory` CHAR(255) NOT NULL, "
677             "`Directory_Parent` CHAR(255), "
678             "`DefaultDir` CHAR(255) NOT NULL "
679             "PRIMARY KEY `Directory`)" );
680     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
681
682     return hdb;
683 }
684
685 static MSIHANDLE package_from_db(MSIHANDLE hdb)
686 {
687     UINT res;
688     CHAR szPackage[10];
689     MSIHANDLE hPackage;
690
691     sprintf(szPackage,"#%i",hdb);
692     res = MsiOpenPackage(szPackage,&hPackage);
693     if (res != ERROR_SUCCESS)
694         return 0;
695
696     res = MsiCloseHandle(hdb);
697     if (res != ERROR_SUCCESS)
698         return 0;
699
700     return hPackage;
701 }
702
703 static void create_test_file(const CHAR *name)
704 {
705     HANDLE file;
706     DWORD written;
707
708     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
709     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
710     WriteFile(file, name, strlen(name), &written, NULL);
711     WriteFile(file, "\n", strlen("\n"), &written, NULL);
712     CloseHandle(file);
713 }
714
715 typedef struct _tagVS_VERSIONINFO
716 {
717     WORD wLength;
718     WORD wValueLength;
719     WORD wType;
720     WCHAR szKey[1];
721     WORD wPadding1[1];
722     VS_FIXEDFILEINFO Value;
723     WORD wPadding2[1];
724     WORD wChildren[1];
725 } VS_VERSIONINFO;
726
727 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
728 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
729
730 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
731 {
732     VS_VERSIONINFO *pVerInfo;
733     VS_FIXEDFILEINFO *pFixedInfo;
734     LPBYTE buffer, ofs;
735     CHAR path[MAX_PATH];
736     DWORD handle, size;
737     HANDLE resource;
738     BOOL ret = FALSE;
739
740     GetSystemDirectory(path, MAX_PATH);
741     lstrcatA(path, "\\kernel32.dll");
742
743     CopyFileA(path, name, FALSE);
744
745     size = GetFileVersionInfoSize(path, &handle);
746     buffer = HeapAlloc(GetProcessHeap(), 0, size);
747
748     GetFileVersionInfoA(path, 0, size, buffer);
749
750     pVerInfo = (VS_VERSIONINFO *)buffer;
751     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
752     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
753
754     pFixedInfo->dwFileVersionMS = ms;
755     pFixedInfo->dwFileVersionLS = ls;
756     pFixedInfo->dwProductVersionMS = ms;
757     pFixedInfo->dwProductVersionLS = ls;
758
759     resource = BeginUpdateResource(name, FALSE);
760     if (!resource)
761         goto done;
762
763     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
764                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
765         goto done;
766
767     if (!EndUpdateResource(resource, FALSE))
768         goto done;
769
770     ret = TRUE;
771
772 done:
773     HeapFree(GetProcessHeap(), 0, buffer);
774     return ret;
775 }
776
777 static void test_createpackage(void)
778 {
779     MSIHANDLE hPackage = 0;
780     UINT res;
781
782     hPackage = package_from_db(create_package_db());
783     ok( hPackage != 0, " Failed to create package\n");
784
785     res = MsiCloseHandle( hPackage);
786     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
787     DeleteFile(msifile);
788 }
789
790 static void test_doaction( void )
791 {
792     MSIHANDLE hpkg;
793     UINT r;
794
795     r = MsiDoAction( -1, NULL );
796     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
797
798     hpkg = package_from_db(create_package_db());
799     ok( hpkg, "failed to create package\n");
800
801     r = MsiDoAction(hpkg, NULL);
802     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
803
804     r = MsiDoAction(0, "boo");
805     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
806
807     r = MsiDoAction(hpkg, "boo");
808     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
809
810     MsiCloseHandle( hpkg );
811     DeleteFile(msifile);
812 }
813
814 static void test_gettargetpath_bad(void)
815 {
816     char buffer[0x80];
817     MSIHANDLE hpkg;
818     DWORD sz;
819     UINT r;
820
821     hpkg = package_from_db(create_package_db());
822     ok( hpkg, "failed to create package\n");
823
824     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
825     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
826
827     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
828     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
829
830     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
831     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
832
833     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
834     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
835
836     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
837     ok( r == ERROR_DIRECTORY, "wrong return val\n");
838
839     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
840     ok( r == ERROR_DIRECTORY, "wrong return val\n");
841
842     MsiCloseHandle( hpkg );
843     DeleteFile(msifile);
844 }
845
846 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
847 {
848     UINT r;
849     DWORD size;
850     MSIHANDLE rec;
851
852     rec = MsiCreateRecord( 1 );
853     ok(rec, "MsiCreate record failed\n");
854
855     r = MsiRecordSetString( rec, 0, file );
856     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
857
858     size = MAX_PATH;
859     r = MsiFormatRecord( hpkg, rec, buff, &size );
860     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
861
862     MsiCloseHandle( rec );
863 }
864
865 static void test_settargetpath(void)
866 {
867     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
868     DWORD sz;
869     MSIHANDLE hpkg;
870     UINT r;
871     MSIHANDLE hdb;
872
873     hdb = create_package_db();
874     ok ( hdb, "failed to create package database\n" );
875
876     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
877     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
878
879     r = create_component_table( hdb );
880     ok( r == S_OK, "cannot create Component table: %d\n", r );
881
882     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
883     ok( r == S_OK, "cannot add dummy component: %d\n", r );
884
885     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
886     ok( r == S_OK, "cannot add test component: %d\n", r );
887
888     r = create_feature_table( hdb );
889     ok( r == S_OK, "cannot create Feature table: %d\n", r );
890
891     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
892     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
893
894     r = create_feature_components_table( hdb );
895     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
896
897     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
898     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
899
900     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
901     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
902
903     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
904     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
905
906     r = create_file_table( hdb );
907     ok( r == S_OK, "cannot create File table: %d\n", r );
908
909     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
910     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
911
912     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
913     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
914
915     hpkg = package_from_db( hdb );
916     ok( hpkg, "failed to create package\n");
917
918     r = MsiDoAction( hpkg, "CostInitialize");
919     ok( r == ERROR_SUCCESS, "cost init failed\n");
920
921     r = MsiDoAction( hpkg, "FileCost");
922     ok( r == ERROR_SUCCESS, "file cost failed\n");
923
924     r = MsiDoAction( hpkg, "CostFinalize");
925     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
926
927     r = MsiSetTargetPath( 0, NULL, NULL );
928     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
929
930     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
931     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
932
933     r = MsiSetTargetPath( hpkg, "boo", NULL );
934     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
935
936     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
937     ok( r == ERROR_DIRECTORY, "wrong return val\n");
938
939     sz = sizeof tempdir - 1;
940     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
941     sprintf( file, "%srootfile.txt", tempdir );
942     buffer[0] = 0;
943     query_file_path( hpkg, "[#RootFile]", buffer );
944     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
945     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
946
947     GetTempFileName( tempdir, "_wt", 0, buffer );
948     sprintf( tempdir, "%s\\subdir", buffer );
949
950     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
951     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
952         "MsiSetTargetPath on file returned %d\n", r );
953
954     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
955     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
956         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
957
958     DeleteFile( buffer );
959
960     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
961     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
962
963     r = GetFileAttributes( buffer );
964     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
965
966     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
967     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
968
969     sz = sizeof buffer - 1;
970     lstrcat( tempdir, "\\" );
971     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
972     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
973     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
974
975     sprintf( file, "%srootfile.txt", tempdir );
976     query_file_path( hpkg, "[#RootFile]", buffer );
977     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
978
979     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
980     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
981
982     query_file_path( hpkg, "[#TestFile]", buffer );
983     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
984         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
985
986     sz = sizeof buffer - 1;
987     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
988     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
989     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
990
991     MsiCloseHandle( hpkg );
992 }
993
994 static void test_condition(void)
995 {
996     MSICONDITION r;
997     MSIHANDLE hpkg;
998
999     hpkg = package_from_db(create_package_db());
1000     ok( hpkg, "failed to create package\n");
1001
1002     r = MsiEvaluateCondition(0, NULL);
1003     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1004
1005     r = MsiEvaluateCondition(hpkg, NULL);
1006     ok( r == MSICONDITION_NONE, "wrong return val\n");
1007
1008     r = MsiEvaluateCondition(hpkg, "");
1009     ok( r == MSICONDITION_NONE, "wrong return val\n");
1010
1011     r = MsiEvaluateCondition(hpkg, "1");
1012     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1013
1014     r = MsiEvaluateCondition(hpkg, "0");
1015     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1016
1017     r = MsiEvaluateCondition(hpkg, "-1");
1018     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1019
1020     r = MsiEvaluateCondition(hpkg, "0 = 0");
1021     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1022
1023     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1024     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1025
1026     r = MsiEvaluateCondition(hpkg, "0 = 1");
1027     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1028
1029     r = MsiEvaluateCondition(hpkg, "0 > 1");
1030     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1031
1032     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1033     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1034
1035     r = MsiEvaluateCondition(hpkg, "1 > 1");
1036     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1037
1038     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1039     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1040
1041     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1042     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1043
1044     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1045     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1046
1047     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1048     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1049
1050     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1051     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1052
1053     r = MsiEvaluateCondition(hpkg, "0 < 1");
1054     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1055
1056     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1057     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1058
1059     r = MsiEvaluateCondition(hpkg, "1 < 1");
1060     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1061
1062     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1063     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1064
1065     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1066     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1067
1068     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1069     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1070
1071     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1072     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1073
1074     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1075     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1076
1077     r = MsiEvaluateCondition(hpkg, "0 >=");
1078     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1079
1080     r = MsiEvaluateCondition(hpkg, " ");
1081     ok( r == MSICONDITION_NONE, "wrong return val\n");
1082
1083     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1084     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1085
1086     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1087     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1088
1089     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1090     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1091
1092     r = MsiEvaluateCondition(hpkg, "not 0");
1093     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1094
1095     r = MsiEvaluateCondition(hpkg, "not LicView");
1096     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1097
1098     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1099     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1100
1101     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1102     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1103
1104     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1105     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1106
1107     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1108     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1109
1110     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1111     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1112
1113     r = MsiEvaluateCondition(hpkg, "\"0\"");
1114     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1115
1116     r = MsiEvaluateCondition(hpkg, "1 and 2");
1117     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1118
1119     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1120     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1121
1122     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1123     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1124
1125     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1126     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1127
1128     r = MsiEvaluateCondition(hpkg, "(0)");
1129     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1130
1131     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1132     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1133
1134     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1135     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1136
1137     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1138     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1139
1140     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1141     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1142
1143     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1144     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1145
1146     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1147     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1148
1149     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1150     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1151
1152     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1153     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1154
1155     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1156     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1157
1158     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1159     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1160
1161     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1162     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1163
1164     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1165     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1166
1167     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1168     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1169
1170     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1171     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1172
1173     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1174     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1175
1176     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1177     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1178
1179     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1180     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1181
1182     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1183     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1184
1185     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1186     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1187
1188     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1189     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1190
1191     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1192     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1193
1194     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1195     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1196
1197     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1198     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1199
1200     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1201     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1202
1203     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1204     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1205
1206     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1207     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1208
1209     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1210     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1211
1212     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1213     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1214
1215     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1216     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1217
1218     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1219     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1220
1221     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1222     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1223
1224     MsiSetProperty(hpkg, "mm", "5" );
1225
1226     r = MsiEvaluateCondition(hpkg, "mm = 5");
1227     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1228
1229     r = MsiEvaluateCondition(hpkg, "mm < 6");
1230     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1231
1232     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1233     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1234
1235     r = MsiEvaluateCondition(hpkg, "mm > 4");
1236     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1237
1238     r = MsiEvaluateCondition(hpkg, "mm < 12");
1239     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1240
1241     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1242     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1243
1244     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1245     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1246
1247     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1248     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1249
1250     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1251     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1252
1253     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1254     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1255
1256     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1257     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258
1259     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1260     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1263     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1266     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1269     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1272     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1275     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1278     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1281     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1284     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1287     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1290     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1293     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1296     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1299     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1302     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1305     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1308     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1311     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1314     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1317     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1318
1319     MsiSetProperty(hpkg, "bandalmael", "0" );
1320     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1321     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1322
1323     MsiSetProperty(hpkg, "bandalmael", "" );
1324     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1325     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1326
1327     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1328     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1329     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330
1331     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1332     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1333     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1334
1335     MsiSetProperty(hpkg, "bandalmael", "0 " );
1336     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1337     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1338
1339     MsiSetProperty(hpkg, "bandalmael", "-0" );
1340     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1341     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1342
1343     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1344     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1345     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1346
1347     MsiSetProperty(hpkg, "bandalmael", "--0" );
1348     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1349     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1350
1351     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1352     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1353     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1354
1355     MsiSetProperty(hpkg, "bandalmael", "-" );
1356     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1357     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1358
1359     MsiSetProperty(hpkg, "bandalmael", "+0" );
1360     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1361     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1362
1363     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1364     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1365     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1366     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1367     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1368
1369     MsiSetProperty(hpkg, "one", "hi");
1370     MsiSetProperty(hpkg, "two", "hithere");
1371     r = MsiEvaluateCondition(hpkg, "one >< two");
1372     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1373
1374     MsiSetProperty(hpkg, "one", "hithere");
1375     MsiSetProperty(hpkg, "two", "hi");
1376     r = MsiEvaluateCondition(hpkg, "one >< two");
1377     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1378
1379     MsiSetProperty(hpkg, "one", "hello");
1380     MsiSetProperty(hpkg, "two", "hi");
1381     r = MsiEvaluateCondition(hpkg, "one >< two");
1382     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1383
1384     MsiSetProperty(hpkg, "one", "hellohithere");
1385     MsiSetProperty(hpkg, "two", "hi");
1386     r = MsiEvaluateCondition(hpkg, "one >< two");
1387     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1388
1389     MsiSetProperty(hpkg, "one", "");
1390     MsiSetProperty(hpkg, "two", "hi");
1391     r = MsiEvaluateCondition(hpkg, "one >< two");
1392     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1393
1394     MsiSetProperty(hpkg, "one", "hi");
1395     MsiSetProperty(hpkg, "two", "");
1396     r = MsiEvaluateCondition(hpkg, "one >< two");
1397     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1398
1399     MsiSetProperty(hpkg, "one", "");
1400     MsiSetProperty(hpkg, "two", "");
1401     r = MsiEvaluateCondition(hpkg, "one >< two");
1402     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1403
1404     MsiSetProperty(hpkg, "one", "1234");
1405     MsiSetProperty(hpkg, "two", "1");
1406     r = MsiEvaluateCondition(hpkg, "one >< two");
1407     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1408
1409     MsiSetProperty(hpkg, "one", "one 1234");
1410     MsiSetProperty(hpkg, "two", "1");
1411     r = MsiEvaluateCondition(hpkg, "one >< two");
1412     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1413
1414     MsiSetProperty(hpkg, "one", "hithere");
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", "hi");
1420     MsiSetProperty(hpkg, "two", "hithere");
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", "hi");
1426     r = MsiEvaluateCondition(hpkg, "one << two");
1427     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429     MsiSetProperty(hpkg, "one", "abcdhithere");
1430     MsiSetProperty(hpkg, "two", "hi");
1431     r = MsiEvaluateCondition(hpkg, "one << two");
1432     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1433
1434     MsiSetProperty(hpkg, "one", "");
1435     MsiSetProperty(hpkg, "two", "hi");
1436     r = MsiEvaluateCondition(hpkg, "one << two");
1437     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1438
1439     MsiSetProperty(hpkg, "one", "hithere");
1440     MsiSetProperty(hpkg, "two", "");
1441     r = MsiEvaluateCondition(hpkg, "one << two");
1442     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444     MsiSetProperty(hpkg, "one", "");
1445     MsiSetProperty(hpkg, "two", "");
1446     r = MsiEvaluateCondition(hpkg, "one << two");
1447     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1448
1449     MsiSetProperty(hpkg, "one", "1234");
1450     MsiSetProperty(hpkg, "two", "1");
1451     r = MsiEvaluateCondition(hpkg, "one << two");
1452     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1453
1454     MsiSetProperty(hpkg, "one", "1234 one");
1455     MsiSetProperty(hpkg, "two", "1");
1456     r = MsiEvaluateCondition(hpkg, "one << two");
1457     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1458
1459     MsiSetProperty(hpkg, "one", "hithere");
1460     MsiSetProperty(hpkg, "two", "there");
1461     r = MsiEvaluateCondition(hpkg, "one >> two");
1462     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1463
1464     MsiSetProperty(hpkg, "one", "hithere");
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", "there");
1470     MsiSetProperty(hpkg, "two", "hithere");
1471     r = MsiEvaluateCondition(hpkg, "one >> two");
1472     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1473
1474     MsiSetProperty(hpkg, "one", "there");
1475     MsiSetProperty(hpkg, "two", "there");
1476     r = MsiEvaluateCondition(hpkg, "one >> two");
1477     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1478
1479     MsiSetProperty(hpkg, "one", "abcdhithere");
1480     MsiSetProperty(hpkg, "two", "hi");
1481     r = MsiEvaluateCondition(hpkg, "one >> two");
1482     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1483
1484     MsiSetProperty(hpkg, "one", "");
1485     MsiSetProperty(hpkg, "two", "there");
1486     r = MsiEvaluateCondition(hpkg, "one >> two");
1487     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1488
1489     MsiSetProperty(hpkg, "one", "there");
1490     MsiSetProperty(hpkg, "two", "");
1491     r = MsiEvaluateCondition(hpkg, "one >> two");
1492     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1493
1494     MsiSetProperty(hpkg, "one", "");
1495     MsiSetProperty(hpkg, "two", "");
1496     r = MsiEvaluateCondition(hpkg, "one >> two");
1497     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1498
1499     MsiSetProperty(hpkg, "one", "1234");
1500     MsiSetProperty(hpkg, "two", "4");
1501     r = MsiEvaluateCondition(hpkg, "one >> two");
1502     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1503
1504     MsiSetProperty(hpkg, "one", "one 1234");
1505     MsiSetProperty(hpkg, "two", "4");
1506     r = MsiEvaluateCondition(hpkg, "one >> two");
1507     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1508
1509     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1510
1511     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1512     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1513
1514     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1515     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1516
1517     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1518     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1519
1520     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1521     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1522
1523     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1524     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1525
1526     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1527     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1528
1529     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1530     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1531
1532     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1533     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1534
1535     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1536     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1537
1538     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1539     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1540
1541     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1542     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1543
1544     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1545     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1546
1547     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1548     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1549
1550     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1551     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1552
1553     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1554     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1555
1556     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1557     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1558
1559     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1560     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1561
1562     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1563     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1564
1565     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1566     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1567
1568     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1569     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1570
1571     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1572     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1573
1574     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1575     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1576
1577     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1578     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1579
1580     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1581     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1582
1583     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1584     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1585
1586     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1587     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1588
1589     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1590     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1591
1592     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1593     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1594
1595     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1596     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1597
1598     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1599     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1600
1601     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
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 < \"{a\"");
1608     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1609
1610     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1611     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1612
1613     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1614     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1615
1616     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1617     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1618
1619     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1620     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1621
1622     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1623     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1624     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1625
1626     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1627     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1628
1629     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1630     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1631
1632     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1633     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1634
1635     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1636     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1637
1638     MsiSetProperty(hpkg, "one", "1");
1639     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1640     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1641
1642     MsiSetProperty(hpkg, "X", "5.0");
1643
1644     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1645     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1646
1647     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1648     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1649
1650     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1651     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1652
1653     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1654     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1655
1656     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1657     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1658
1659     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1660     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1661
1662     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1663     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1664
1665     /* feature doesn't exist */
1666     r = MsiEvaluateCondition(hpkg, "&nofeature");
1667     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1668
1669     MsiSetProperty(hpkg, "A", "2");
1670     MsiSetProperty(hpkg, "X", "50");
1671
1672     r = MsiEvaluateCondition(hpkg, "2 <= X");
1673     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1674
1675     r = MsiEvaluateCondition(hpkg, "A <= X");
1676     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1677
1678     r = MsiEvaluateCondition(hpkg, "A <= 50");
1679     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1680
1681     MsiSetProperty(hpkg, "X", "50val");
1682
1683     r = MsiEvaluateCondition(hpkg, "2 <= X");
1684     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1685
1686     r = MsiEvaluateCondition(hpkg, "A <= X");
1687     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1688
1689     MsiSetProperty(hpkg, "A", "7");
1690     MsiSetProperty(hpkg, "X", "50");
1691
1692     r = MsiEvaluateCondition(hpkg, "7 <= X");
1693     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1694
1695     r = MsiEvaluateCondition(hpkg, "A <= X");
1696     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1697
1698     r = MsiEvaluateCondition(hpkg, "A <= 50");
1699     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1700
1701     MsiSetProperty(hpkg, "X", "50val");
1702
1703     r = MsiEvaluateCondition(hpkg, "2 <= X");
1704     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1705
1706     r = MsiEvaluateCondition(hpkg, "A <= X");
1707     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1708
1709     MsiCloseHandle( hpkg );
1710     DeleteFile(msifile);
1711 }
1712
1713 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1714 {
1715     UINT r;
1716     DWORD sz;
1717     char buffer[2];
1718
1719     sz = sizeof buffer;
1720     strcpy(buffer,"x");
1721     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1722     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1723 }
1724
1725 static void test_props(void)
1726 {
1727     MSIHANDLE hpkg, hdb;
1728     UINT r;
1729     DWORD sz;
1730     char buffer[0x100];
1731
1732     hdb = create_package_db();
1733     r = run_query( hdb,
1734             "CREATE TABLE `Property` ( "
1735             "`Property` CHAR(255) NOT NULL, "
1736             "`Value` CHAR(255) "
1737             "PRIMARY KEY `Property`)" );
1738     ok( r == ERROR_SUCCESS , "Failed\n" );
1739
1740     r = run_query(hdb,
1741             "INSERT INTO `Property` "
1742             "(`Property`, `Value`) "
1743             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1744     ok( r == ERROR_SUCCESS , "Failed\n" );
1745
1746     hpkg = package_from_db( hdb );
1747     ok( hpkg, "failed to create package\n");
1748
1749     /* test invalid values */
1750     r = MsiGetProperty( 0, NULL, NULL, NULL );
1751     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1752
1753     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1754     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1755
1756     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1757     ok( r == ERROR_SUCCESS, "wrong return val\n");
1758
1759     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1760     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1761
1762     /* test retrieving an empty/nonexistent property */
1763     sz = sizeof buffer;
1764     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1765     ok( r == ERROR_SUCCESS, "wrong return val\n");
1766     ok( sz == 0, "wrong size returned\n");
1767
1768     check_prop_empty( hpkg, "boo");
1769     sz = 0;
1770     strcpy(buffer,"x");
1771     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1772     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1773     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1774     ok( sz == 0, "wrong size returned\n");
1775
1776     sz = 1;
1777     strcpy(buffer,"x");
1778     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1779     ok( r == ERROR_SUCCESS, "wrong return val\n");
1780     ok( buffer[0] == 0, "buffer was not changed\n");
1781     ok( sz == 0, "wrong size returned\n");
1782
1783     /* set the property to something */
1784     r = MsiSetProperty( 0, NULL, NULL );
1785     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1786
1787     r = MsiSetProperty( hpkg, NULL, NULL );
1788     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1789
1790     r = MsiSetProperty( hpkg, "", NULL );
1791     ok( r == ERROR_SUCCESS, "wrong return val\n");
1792
1793     /* try set and get some illegal property identifiers */
1794     r = MsiSetProperty( hpkg, "", "asdf" );
1795     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1796
1797     r = MsiSetProperty( hpkg, "=", "asdf" );
1798     ok( r == ERROR_SUCCESS, "wrong return val\n");
1799
1800     r = MsiSetProperty( hpkg, " ", "asdf" );
1801     ok( r == ERROR_SUCCESS, "wrong return val\n");
1802
1803     r = MsiSetProperty( hpkg, "'", "asdf" );
1804     ok( r == ERROR_SUCCESS, "wrong return val\n");
1805
1806     sz = sizeof buffer;
1807     buffer[0]=0;
1808     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1809     ok( r == ERROR_SUCCESS, "wrong return val\n");
1810     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1811
1812     /* set empty values */
1813     r = MsiSetProperty( hpkg, "boo", NULL );
1814     ok( r == ERROR_SUCCESS, "wrong return val\n");
1815     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1816
1817     r = MsiSetProperty( hpkg, "boo", "" );
1818     ok( r == ERROR_SUCCESS, "wrong return val\n");
1819     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1820
1821     /* set a non-empty value */
1822     r = MsiSetProperty( hpkg, "boo", "xyz" );
1823     ok( r == ERROR_SUCCESS, "wrong return val\n");
1824
1825     sz = 1;
1826     strcpy(buffer,"x");
1827     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1828     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1829     ok( buffer[0] == 0, "buffer was not changed\n");
1830     ok( sz == 3, "wrong size returned\n");
1831
1832     sz = 4;
1833     strcpy(buffer,"x");
1834     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1835     ok( r == ERROR_SUCCESS, "wrong return val\n");
1836     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1837     ok( sz == 3, "wrong size returned\n");
1838
1839     sz = 3;
1840     strcpy(buffer,"x");
1841     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1842     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1843     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1844     ok( sz == 3, "wrong size returned\n");
1845
1846     r = MsiSetProperty(hpkg, "SourceDir", "foo");
1847     ok( r == ERROR_SUCCESS, "wrong return val\n");
1848
1849     sz = 4;
1850     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1851     ok( r == ERROR_SUCCESS, "wrong return val\n");
1852     ok( !strcmp(buffer,""), "buffer wrong\n");
1853     ok( sz == 0, "wrong size returned\n");
1854
1855     sz = 4;
1856     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1857     ok( r == ERROR_SUCCESS, "wrong return val\n");
1858     ok( !strcmp(buffer,""), "buffer wrong\n");
1859     ok( sz == 0, "wrong size returned\n");
1860
1861     sz = 4;
1862     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1863     ok( r == ERROR_SUCCESS, "wrong return val\n");
1864     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1865     ok( sz == 3, "wrong size returned\n");
1866
1867     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1868     ok( r == ERROR_SUCCESS, "wrong return val\n");
1869
1870     sz = 0;
1871     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1872     ok( r == ERROR_SUCCESS, "return wrong\n");
1873     ok( sz == 13, "size wrong (%d)\n", sz);
1874
1875     sz = 13;
1876     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1877     ok( r == ERROR_MORE_DATA, "return wrong\n");
1878     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1879
1880     r = MsiSetProperty(hpkg, "property", "value");
1881     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1882
1883     sz = 6;
1884     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1885     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1886     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1887
1888     r = MsiSetProperty(hpkg, "property", NULL);
1889     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1890
1891     sz = 6;
1892     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1893     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1894     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1895
1896     MsiCloseHandle( hpkg );
1897     DeleteFile(msifile);
1898 }
1899
1900 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
1901 {
1902     MSIHANDLE hview, hrec;
1903     BOOL found;
1904     CHAR buffer[MAX_PATH];
1905     DWORD sz;
1906     UINT r;
1907
1908     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
1909     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1910     r = MsiViewExecute(hview, 0);
1911     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
1912
1913     found = FALSE;
1914     while (r == ERROR_SUCCESS && !found)
1915     {
1916         r = MsiViewFetch(hview, &hrec);
1917         if (r != ERROR_SUCCESS) break;
1918
1919         sz = MAX_PATH;
1920         r = MsiRecordGetString(hrec, 1, buffer, &sz);
1921         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
1922         {
1923             sz = MAX_PATH;
1924             r = MsiRecordGetString(hrec, 2, buffer, &sz);
1925             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
1926                 found = TRUE;
1927         }
1928
1929         MsiCloseHandle(hrec);
1930     }
1931
1932     MsiViewClose(hview);
1933     MsiCloseHandle(hview);
1934
1935     return found;
1936 }
1937
1938 static void test_property_table(void)
1939 {
1940     const char *query;
1941     UINT r;
1942     MSIHANDLE hpkg, hdb, hrec;
1943     char buffer[MAX_PATH];
1944     DWORD sz;
1945     BOOL found;
1946
1947     hdb = create_package_db();
1948     ok( hdb, "failed to create package\n");
1949
1950     hpkg = package_from_db(hdb);
1951     ok( hpkg, "failed to create package\n");
1952
1953     MsiCloseHandle(hdb);
1954
1955     hdb = MsiGetActiveDatabase(hpkg);
1956
1957     query = "CREATE TABLE `_Property` ( "
1958         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1959     r = run_query(hdb, query);
1960     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1961
1962     MsiCloseHandle(hdb);
1963     MsiCloseHandle(hpkg);
1964     DeleteFile(msifile);
1965
1966     hdb = create_package_db();
1967     ok( hdb, "failed to create package\n");
1968
1969     query = "CREATE TABLE `_Property` ( "
1970         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1971     r = run_query(hdb, query);
1972     ok(r == ERROR_SUCCESS, "failed to create table\n");
1973
1974     query = "ALTER `_Property` ADD `foo` INTEGER";
1975     r = run_query(hdb, query);
1976     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1977
1978     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
1979     r = run_query(hdb, query);
1980     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1981
1982     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
1983     r = run_query(hdb, query);
1984     ok(r == ERROR_SUCCESS, "failed to add column\n");
1985
1986     hpkg = package_from_db(hdb);
1987     todo_wine
1988     {
1989         ok(!hpkg, "package should not be created\n");
1990     }
1991
1992     MsiCloseHandle(hdb);
1993     MsiCloseHandle(hpkg);
1994     DeleteFile(msifile);
1995
1996     hdb = create_package_db();
1997     ok (hdb, "failed to create package database\n");
1998
1999     r = create_property_table(hdb);
2000     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2001
2002     r = add_property_entry(hdb, "'prop', 'val'");
2003     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2004
2005     hpkg = package_from_db(hdb);
2006     ok(hpkg, "failed to create package\n");
2007
2008     MsiCloseHandle(hdb);
2009
2010     sz = MAX_PATH;
2011     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2013     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2014
2015     hdb = MsiGetActiveDatabase(hpkg);
2016
2017     found = find_prop_in_property(hdb, "prop", "val");
2018     ok(found, "prop should be in the _Property table\n");
2019
2020     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2021     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2022
2023     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2024     r = do_query(hdb, query, &hrec);
2025     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2026
2027     found = find_prop_in_property(hdb, "dantes", "mercedes");
2028     ok(found == FALSE, "dantes should not be in the _Property table\n");
2029
2030     sz = MAX_PATH;
2031     lstrcpy(buffer, "aaa");
2032     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2034     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2035
2036     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2037     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2038
2039     found = find_prop_in_property(hdb, "dantes", "mercedes");
2040     ok(found == TRUE, "dantes should be in the _Property table\n");
2041
2042     MsiCloseHandle(hdb);
2043     MsiCloseHandle(hpkg);
2044     DeleteFile(msifile);
2045 }
2046
2047 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2048 {
2049     MSIHANDLE htab = 0;
2050     UINT res;
2051
2052     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2053     if( res == ERROR_SUCCESS )
2054     {
2055         UINT r;
2056
2057         r = MsiViewExecute( htab, hrec );
2058         if( r != ERROR_SUCCESS )
2059         {
2060             res = r;
2061             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2062         }
2063
2064         r = MsiViewClose( htab );
2065         if( r != ERROR_SUCCESS )
2066             res = r;
2067
2068         r = MsiCloseHandle( htab );
2069         if( r != ERROR_SUCCESS )
2070             res = r;
2071     }
2072     return res;
2073 }
2074
2075 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2076 {
2077     return try_query_param( hdb, szQuery, 0 );
2078 }
2079
2080 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2081 {
2082     MSIHANDLE summary;
2083     UINT r;
2084
2085     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2086     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2087
2088     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2089     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2090
2091     r = MsiSummaryInfoPersist(summary);
2092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2093
2094     MsiCloseHandle(summary);
2095 }
2096
2097 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2098 {
2099     MSIHANDLE summary;
2100     UINT r;
2101
2102     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2103     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2104
2105     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2106     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2107
2108     r = MsiSummaryInfoPersist(summary);
2109     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2110
2111     MsiCloseHandle(summary);
2112 }
2113
2114 static void test_msipackage(void)
2115 {
2116     MSIHANDLE hdb = 0, hpack = 100;
2117     UINT r;
2118     const char *query;
2119     char name[10];
2120
2121     /* NULL szPackagePath */
2122     r = MsiOpenPackage(NULL, &hpack);
2123     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2124
2125     /* empty szPackagePath */
2126     r = MsiOpenPackage("", &hpack);
2127     todo_wine
2128     {
2129         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2130     }
2131
2132     if (r == ERROR_SUCCESS)
2133         MsiCloseHandle(hpack);
2134
2135     /* nonexistent szPackagePath */
2136     r = MsiOpenPackage("nonexistent", &hpack);
2137     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2138
2139     /* NULL hProduct */
2140     r = MsiOpenPackage(msifile, NULL);
2141     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2142
2143     name[0]='#';
2144     name[1]=0;
2145     r = MsiOpenPackage(name, &hpack);
2146     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2147
2148     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2149     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2150
2151     /* database exists, but is emtpy */
2152     sprintf(name, "#%d", hdb);
2153     r = MsiOpenPackage(name, &hpack);
2154     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2155        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2156
2157     query = "CREATE TABLE `Property` ( "
2158             "`Property` CHAR(72), `Value` CHAR(0) "
2159             "PRIMARY KEY `Property`)";
2160     r = try_query(hdb, query);
2161     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2162
2163     query = "CREATE TABLE `InstallExecuteSequence` ("
2164             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2165             "PRIMARY KEY `Action`)";
2166     r = try_query(hdb, query);
2167     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2168
2169     /* a few key tables exist */
2170     sprintf(name, "#%d", hdb);
2171     r = MsiOpenPackage(name, &hpack);
2172     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2173        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2174
2175     MsiCloseHandle(hdb);
2176     DeleteFile(msifile);
2177
2178     /* start with a clean database to show what constitutes a valid package */
2179     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2180     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2181
2182     sprintf(name, "#%d", hdb);
2183
2184     /* The following summary information props must exist:
2185      *  - PID_REVNUMBER
2186      *  - PID_PAGECOUNT
2187      */
2188
2189     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2190     r = MsiOpenPackage(name, &hpack);
2191     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2192        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2193
2194     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2195     r = MsiOpenPackage(name, &hpack);
2196     ok(r == ERROR_SUCCESS,
2197        "Expected ERROR_SUCCESS, got %d\n", r);
2198
2199     MsiCloseHandle(hpack);
2200     MsiCloseHandle(hdb);
2201     DeleteFile(msifile);
2202 }
2203
2204 static void test_formatrecord2(void)
2205 {
2206     MSIHANDLE hpkg, hrec ;
2207     char buffer[0x100];
2208     DWORD sz;
2209     UINT r;
2210
2211     hpkg = package_from_db(create_package_db());
2212     ok( hpkg, "failed to create package\n");
2213
2214     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2215     ok( r == ERROR_SUCCESS, "set property failed\n");
2216
2217     hrec = MsiCreateRecord(2);
2218     ok(hrec, "create record failed\n");
2219
2220     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2221     ok( r == ERROR_SUCCESS, "format record failed\n");
2222
2223     buffer[0] = 0;
2224     sz = sizeof buffer;
2225     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2226
2227     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2228     r = MsiRecordSetString(hrec, 1, "hoo");
2229     sz = sizeof buffer;
2230     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2231     ok( sz == 3, "size wrong\n");
2232     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2233     ok( r == ERROR_SUCCESS, "format failed\n");
2234
2235     r = MsiRecordSetString(hrec, 0, "x[~]x");
2236     sz = sizeof buffer;
2237     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2238     ok( sz == 3, "size wrong\n");
2239     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2240     ok( r == ERROR_SUCCESS, "format failed\n");
2241
2242     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2243     r = MsiRecordSetString(hrec, 1, "hoo");
2244     sz = sizeof buffer;
2245     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2246     ok( sz == 3, "size wrong\n");
2247     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2248     ok( r == ERROR_SUCCESS, "format failed\n");
2249
2250     r = MsiRecordSetString(hrec, 0, "[\\[]");
2251     sz = sizeof buffer;
2252     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2253     ok( sz == 1, "size wrong\n");
2254     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2255     ok( r == ERROR_SUCCESS, "format failed\n");
2256
2257     SetEnvironmentVariable("FOO", "BAR");
2258     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2259     sz = sizeof buffer;
2260     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2261     ok( sz == 3, "size wrong\n");
2262     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2263     ok( r == ERROR_SUCCESS, "format failed\n");
2264
2265     r = MsiRecordSetString(hrec, 0, "[[1]]");
2266     r = MsiRecordSetString(hrec, 1, "%FOO");
2267     sz = sizeof buffer;
2268     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2269     ok( sz == 3, "size wrong\n");
2270     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2271     ok( r == ERROR_SUCCESS, "format failed\n");
2272
2273     MsiCloseHandle( hrec );
2274     MsiCloseHandle( hpkg );
2275     DeleteFile(msifile);
2276 }
2277
2278 static void test_states(void)
2279 {
2280     MSIHANDLE hpkg;
2281     UINT r;
2282     MSIHANDLE hdb;
2283     INSTALLSTATE state, action;
2284
2285     static const CHAR msifile2[] = "winetest2.msi";
2286     static const CHAR msifile3[] = "winetest3.msi";
2287     static const CHAR msifile4[] = "winetest4.msi";
2288
2289     hdb = create_package_db();
2290     ok ( hdb, "failed to create package database\n" );
2291
2292     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2293     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2294
2295     r = create_property_table( hdb );
2296     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2297
2298     r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2299     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2300
2301     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2302     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2303
2304     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2305     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2306
2307     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2308     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2309
2310     r = create_install_execute_sequence_table( hdb );
2311     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2312
2313     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2314     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2315
2316     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2317     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2318
2319     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2320     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2321
2322     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2323     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2324
2325     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2326     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2327
2328     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2329     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2330
2331     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2332     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2333
2334     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2335     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2336
2337     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2338     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2339
2340     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2341     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2342
2343     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2344     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2345
2346     r = create_media_table( hdb );
2347     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2348
2349     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2350     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2351
2352     r = create_feature_table( hdb );
2353     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2354
2355     r = create_component_table( hdb );
2356     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2357
2358     /* msidbFeatureAttributesFavorLocal */
2359     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2360     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2361
2362     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2363     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2364     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2365
2366     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2367     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2368     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2369
2370     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2371     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2372     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2373
2374     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2375     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2376     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2377
2378     /* msidbFeatureAttributesFavorSource */
2379     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2380     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2381
2382     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2383     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2384     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2385
2386     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2387     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2388     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2389
2390     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2391     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2392     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2393
2394     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2395     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2396     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2397
2398     /* msidbFeatureAttributesFavorSource */
2399     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2400     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2401
2402     /* msidbFeatureAttributesFavorLocal */
2403     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2404     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2405
2406     /* disabled */
2407     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2408     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2409
2410     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2411     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2412     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2413
2414     /* no feature parent:msidbComponentAttributesLocalOnly */
2415     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2416     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2417
2418     /* msidbFeatureAttributesFavorLocal:removed */
2419     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2420     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2421
2422     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2423     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2424     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2425
2426     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2427     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2428     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2429
2430     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2431     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2432     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2433
2434     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2435     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2436     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2437
2438     /* msidbFeatureAttributesFavorSource:removed */
2439     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2440     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2441
2442     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2443     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2444     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2445
2446     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2447     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2448     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2449
2450     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2451     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2452     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2453
2454     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2455     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2456     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2457
2458     /* msidbFeatureAttributesFavorLocal */
2459     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2460     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2461
2462     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2463     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2464
2465     /* msidbFeatureAttributesFavorSource */
2466     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2467     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2468
2469     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2470     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2471
2472     /* msidbFeatureAttributesFavorAdvertise */
2473     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2474     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2475
2476     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2477     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2478
2479     r = create_feature_components_table( hdb );
2480     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2481
2482     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2483     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2484
2485     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2486     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2487
2488     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2489     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2490
2491     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2492     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2493
2494     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2495     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2496
2497     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2498     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2499
2500     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2501     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2502
2503     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2504     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2505
2506     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2507     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2508
2509     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2510     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2511
2512     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2513     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2514
2515     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2516     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2517
2518     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2519     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2520
2521     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2522     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2523
2524     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2525     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2526
2527     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2528     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2529
2530     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2531     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2532
2533     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2534     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2535
2536     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2537     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2538
2539     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2540     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2541
2542     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2543     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2544
2545     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2546     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2547
2548     r = create_file_table( hdb );
2549     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2550
2551     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2552     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2553
2554     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2555     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2556
2557     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2558     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2559
2560     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2561     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2562
2563     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2564     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2565
2566     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2567     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2568
2569     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2570     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2571
2572     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2573     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2574
2575     /* compressed file */
2576     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2577     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2578
2579     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2580     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2581
2582     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2583     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2584
2585     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2586     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2587
2588     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2589     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2590
2591     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2592     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2593
2594     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2595     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2596
2597     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2598     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2599
2600     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2601     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2602
2603     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2604     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2605
2606     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2607     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2608
2609     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2610     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2611
2612     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2613     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2614
2615     MsiDatabaseCommit(hdb);
2616
2617     /* these properties must not be in the saved msi file */
2618     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2619     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2620
2621     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2622     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2623
2624     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2625     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2626
2627     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2628     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2629
2630     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2631     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2632
2633     hpkg = package_from_db( hdb );
2634     ok( hpkg, "failed to create package\n");
2635
2636     MsiCloseHandle(hdb);
2637
2638     CopyFileA(msifile, msifile2, FALSE);
2639     CopyFileA(msifile, msifile3, FALSE);
2640     CopyFileA(msifile, msifile4, FALSE);
2641
2642     state = 0xdeadbee;
2643     action = 0xdeadbee;
2644     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2645     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2646     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2647     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2648
2649     state = 0xdeadbee;
2650     action = 0xdeadbee;
2651     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2652     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2653     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2654     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2655
2656     state = 0xdeadbee;
2657     action = 0xdeadbee;
2658     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2659     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2660     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2661     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2662
2663     state = 0xdeadbee;
2664     action = 0xdeadbee;
2665     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2666     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2667     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2668     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2669
2670     state = 0xdeadbee;
2671     action = 0xdeadbee;
2672     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2673     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2674     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2675     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2676
2677     state = 0xdeadbee;
2678     action = 0xdeadbee;
2679     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2680     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2681     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2682     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2683
2684     state = 0xdeadbee;
2685     action = 0xdeadbee;
2686     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2687     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2688     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2689     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2690
2691     state = 0xdeadbee;
2692     action = 0xdeadbee;
2693     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2694     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2695     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2696     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2697
2698     state = 0xdeadbee;
2699     action = 0xdeadbee;
2700     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2701     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2702     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2703     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2704
2705     state = 0xdeadbee;
2706     action = 0xdeadbee;
2707     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2708     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2709     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2710     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2711
2712     state = 0xdeadbee;
2713     action = 0xdeadbee;
2714     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2715     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2716     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2717     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2718
2719     state = 0xdeadbee;
2720     action = 0xdeadbee;
2721     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2722     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2723     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2724     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2725
2726     state = 0xdeadbee;
2727     action = 0xdeadbee;
2728     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2729     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2730     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2731     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2732
2733     state = 0xdeadbee;
2734     action = 0xdeadbee;
2735     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2736     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2737     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2738     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2739
2740     state = 0xdeadbee;
2741     action = 0xdeadbee;
2742     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2743     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2744     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2745     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2746
2747     state = 0xdeadbee;
2748     action = 0xdeadbee;
2749     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2750     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2751     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2752     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2753
2754     state = 0xdeadbee;
2755     action = 0xdeadbee;
2756     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2757     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2758     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2759     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2760
2761     state = 0xdeadbee;
2762     action = 0xdeadbee;
2763     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2764     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2765     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2766     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2767
2768     state = 0xdeadbee;
2769     action = 0xdeadbee;
2770     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2771     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2772     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2773     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2774
2775     state = 0xdeadbee;
2776     action = 0xdeadbee;
2777     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2778     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2779     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2780     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2781
2782     state = 0xdeadbee;
2783     action = 0xdeadbee;
2784     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2785     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2786     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2787     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2788
2789     state = 0xdeadbee;
2790     action = 0xdeadbee;
2791     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2792     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2793     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2794     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2795
2796     state = 0xdeadbee;
2797     action = 0xdeadbee;
2798     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2799     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2800     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2801     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2802
2803     state = 0xdeadbee;
2804     action = 0xdeadbee;
2805     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2806     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2807     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2808     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2809
2810     state = 0xdeadbee;
2811     action = 0xdeadbee;
2812     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2813     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2814     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2815     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2816
2817     state = 0xdeadbee;
2818     action = 0xdeadbee;
2819     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2820     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2821     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2822     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2823
2824     state = 0xdeadbee;
2825     action = 0xdeadbee;
2826     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2827     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2828     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2829     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2830
2831     state = 0xdeadbee;
2832     action = 0xdeadbee;
2833     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2834     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2835     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2836     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2837
2838     state = 0xdeadbee;
2839     action = 0xdeadbee;
2840     r = MsiGetComponentState(hpkg, "tau", &state, &action);
2841     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2842     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2843     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2844
2845     state = 0xdeadbee;
2846     action = 0xdeadbee;
2847     r = MsiGetComponentState(hpkg, "phi", &state, &action);
2848     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2849     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2850     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2851
2852     state = 0xdeadbee;
2853     action = 0xdeadbee;
2854     r = MsiGetComponentState(hpkg, "chi", &state, &action);
2855     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2856     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2857     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2858
2859     r = MsiDoAction( hpkg, "CostInitialize");
2860     ok( r == ERROR_SUCCESS, "cost init failed\n");
2861
2862     state = 0xdeadbee;
2863     action = 0xdeadbee;
2864     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2865     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2866     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2867     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2868
2869     state = 0xdeadbee;
2870     action = 0xdeadbee;
2871     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2872     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2873     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2874     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2875
2876     state = 0xdeadbee;
2877     action = 0xdeadbee;
2878     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2879     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2880     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2881     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2882
2883     state = 0xdeadbee;
2884     action = 0xdeadbee;
2885     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2886     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2887     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2888     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2889
2890     state = 0xdeadbee;
2891     action = 0xdeadbee;
2892     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2893     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2894     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2895     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2896
2897     state = 0xdeadbee;
2898     action = 0xdeadbee;
2899     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2900     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2901     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2902     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2903
2904     state = 0xdeadbee;
2905     action = 0xdeadbee;
2906     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2907     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2908     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2909     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2910
2911     state = 0xdeadbee;
2912     action = 0xdeadbee;
2913     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2914     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2915     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2916     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2917
2918     state = 0xdeadbee;
2919     action = 0xdeadbee;
2920     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2921     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2922     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2923     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2924
2925     state = 0xdeadbee;
2926     action = 0xdeadbee;
2927     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2928     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2929     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2930     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2931
2932     state = 0xdeadbee;
2933     action = 0xdeadbee;
2934     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2935     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2936     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2937     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2938
2939     state = 0xdeadbee;
2940     action = 0xdeadbee;
2941     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2942     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2943     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2944     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2945
2946     state = 0xdeadbee;
2947     action = 0xdeadbee;
2948     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2949     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2950     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2951     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2952
2953     state = 0xdeadbee;
2954     action = 0xdeadbee;
2955     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2956     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2957     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2958     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2959
2960     state = 0xdeadbee;
2961     action = 0xdeadbee;
2962     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2963     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2964     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2965     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2966
2967     state = 0xdeadbee;
2968     action = 0xdeadbee;
2969     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2970     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2971     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2972     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2973
2974     state = 0xdeadbee;
2975     action = 0xdeadbee;
2976     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2977     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2978     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2979     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2980
2981     state = 0xdeadbee;
2982     action = 0xdeadbee;
2983     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2984     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2985     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2986     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2987
2988     state = 0xdeadbee;
2989     action = 0xdeadbee;
2990     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2991     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2992     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2993     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2994
2995     state = 0xdeadbee;
2996     action = 0xdeadbee;
2997     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2998     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2999     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3000     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3001
3002     state = 0xdeadbee;
3003     action = 0xdeadbee;
3004     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3005     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3006     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3007     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3008
3009     state = 0xdeadbee;
3010     action = 0xdeadbee;
3011     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3012     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3013     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3014     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3015
3016     state = 0xdeadbee;
3017     action = 0xdeadbee;
3018     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3019     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3020     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3021     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3022
3023     state = 0xdeadbee;
3024     action = 0xdeadbee;
3025     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3026     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3027     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3028     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3029
3030     state = 0xdeadbee;
3031     action = 0xdeadbee;
3032     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3034     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3035     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3036
3037     state = 0xdeadbee;
3038     action = 0xdeadbee;
3039     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3040     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3041     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3042     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3043
3044     state = 0xdeadbee;
3045     action = 0xdeadbee;
3046     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3047     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3048     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3049     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3050
3051     state = 0xdeadbee;
3052     action = 0xdeadbee;
3053     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3055     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3056     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3057
3058     state = 0xdeadbee;
3059     action = 0xdeadbee;
3060     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3061     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3062     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3063     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3064
3065     state = 0xdeadbee;
3066     action = 0xdeadbee;
3067     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3068     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3069     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3070     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3071
3072     state = 0xdeadbee;
3073     action = 0xdeadbee;
3074     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3075     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3076     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3077     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3078
3079     r = MsiDoAction( hpkg, "FileCost");
3080     ok( r == ERROR_SUCCESS, "file cost failed\n");
3081
3082     state = 0xdeadbee;
3083     action = 0xdeadbee;
3084     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3086     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3087     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3088
3089     state = 0xdeadbee;
3090     action = 0xdeadbee;
3091     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3093     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3094     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3095
3096     state = 0xdeadbee;
3097     action = 0xdeadbee;
3098     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3100     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3101     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3102
3103     state = 0xdeadbee;
3104     action = 0xdeadbee;
3105     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3107     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3108     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3109
3110     state = 0xdeadbee;
3111     action = 0xdeadbee;
3112     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3114     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3115     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3116
3117     state = 0xdeadbee;
3118     action = 0xdeadbee;
3119     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3121     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3122     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3123
3124     state = 0xdeadbee;
3125     action = 0xdeadbee;
3126     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3128     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3129     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3130
3131     state = 0xdeadbee;
3132     action = 0xdeadbee;
3133     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3135     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3136     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3137
3138     state = 0xdeadbee;
3139     action = 0xdeadbee;
3140     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3142     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3143     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3144
3145     state = 0xdeadbee;
3146     action = 0xdeadbee;
3147     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3149     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3150     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3151
3152     state = 0xdeadbee;
3153     action = 0xdeadbee;
3154     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3156     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3157     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3158
3159     state = 0xdeadbee;
3160     action = 0xdeadbee;
3161     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3163     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3164     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3165
3166     state = 0xdeadbee;
3167     action = 0xdeadbee;
3168     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3170     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3171     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3172
3173     state = 0xdeadbee;
3174     action = 0xdeadbee;
3175     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3177     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3178     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3179
3180     state = 0xdeadbee;
3181     action = 0xdeadbee;
3182     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3184     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3185     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3186
3187     state = 0xdeadbee;
3188     action = 0xdeadbee;
3189     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3191     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3192     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3193
3194     state = 0xdeadbee;
3195     action = 0xdeadbee;
3196     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3197     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3198     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3199     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3200
3201     state = 0xdeadbee;
3202     action = 0xdeadbee;
3203     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3204     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3205     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3206     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3207
3208     state = 0xdeadbee;
3209     action = 0xdeadbee;
3210     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3211     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3212     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3213     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3214
3215     state = 0xdeadbee;
3216     action = 0xdeadbee;
3217     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3218     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3219     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3220     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3221
3222     state = 0xdeadbee;
3223     action = 0xdeadbee;
3224     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3225     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3226     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3227     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3228
3229     state = 0xdeadbee;
3230     action = 0xdeadbee;
3231     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3232     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3233     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3234     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3235
3236     state = 0xdeadbee;
3237     action = 0xdeadbee;
3238     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3239     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3240     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3241     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3242
3243     state = 0xdeadbee;
3244     action = 0xdeadbee;
3245     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3246     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3247     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3248     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3249
3250     state = 0xdeadbee;
3251     action = 0xdeadbee;
3252     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3253     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3254     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3255     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3256
3257     state = 0xdeadbee;
3258     action = 0xdeadbee;
3259     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3260     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3261     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3262     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3263
3264     state = 0xdeadbee;
3265     action = 0xdeadbee;
3266     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3267     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3268     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3269     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3270
3271     state = 0xdeadbee;
3272     action = 0xdeadbee;
3273     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3274     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3275     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3276     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3277
3278     state = 0xdeadbee;
3279     action = 0xdeadbee;
3280     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3281     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3282     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3283     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3284
3285     state = 0xdeadbee;
3286     action = 0xdeadbee;
3287     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3288     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3289     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3290     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3291
3292     state = 0xdeadbee;
3293     action = 0xdeadbee;
3294     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3295     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3296     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3297     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3298
3299     r = MsiDoAction( hpkg, "CostFinalize");
3300     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3301
3302     state = 0xdeadbee;
3303     action = 0xdeadbee;
3304     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3305     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3306     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3307     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3308
3309     state = 0xdeadbee;
3310     action = 0xdeadbee;
3311     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3312     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3313     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3314     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3315
3316     state = 0xdeadbee;
3317     action = 0xdeadbee;
3318     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3319     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3320     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3321     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3322
3323     state = 0xdeadbee;
3324     action = 0xdeadbee;
3325     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3326     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3327     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3328     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3329
3330     state = 0xdeadbee;
3331     action = 0xdeadbee;
3332     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3333     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3334     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3335     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3336
3337     state = 0xdeadbee;
3338     action = 0xdeadbee;
3339     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3340     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3341     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3342     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3343
3344     state = 0xdeadbee;
3345     action = 0xdeadbee;
3346     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3347     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3348     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3349     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3350
3351     state = 0xdeadbee;
3352     action = 0xdeadbee;
3353     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3354     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3355     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3356     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3357
3358     state = 0xdeadbee;
3359     action = 0xdeadbee;
3360     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3361     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3362     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3363     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3364
3365     state = 0xdeadbee;
3366     action = 0xdeadbee;
3367     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3368     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3369     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3370     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3371
3372     state = 0xdeadbee;
3373     action = 0xdeadbee;
3374     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3375     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3376     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3377     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3378
3379     state = 0xdeadbee;
3380     action = 0xdeadbee;
3381     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3382     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3383     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3384     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3385
3386     state = 0xdeadbee;
3387     action = 0xdeadbee;
3388     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3389     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3390     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3391     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3392
3393     state = 0xdeadbee;
3394     action = 0xdeadbee;
3395     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3396     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3397     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3398     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3399
3400     state = 0xdeadbee;
3401     action = 0xdeadbee;
3402     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3403     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3404     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3405     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3406
3407     state = 0xdeadbee;
3408     action = 0xdeadbee;
3409     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3410     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3411     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3412     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3413
3414     state = 0xdeadbee;
3415     action = 0xdeadbee;
3416     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3417     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3418     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3419     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3420
3421     state = 0xdeadbee;
3422     action = 0xdeadbee;
3423     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3424     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3425     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3426     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3427
3428     state = 0xdeadbee;
3429     action = 0xdeadbee;
3430     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3431     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3432     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3433     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3434
3435     state = 0xdeadbee;
3436     action = 0xdeadbee;
3437     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3438     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3439     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3440     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3441
3442     state = 0xdeadbee;
3443     action = 0xdeadbee;
3444     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3445     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3446     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3447     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3448
3449     state = 0xdeadbee;
3450     action = 0xdeadbee;
3451     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3452     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3453     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3454     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3455
3456     state = 0xdeadbee;
3457     action = 0xdeadbee;
3458     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3459     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3460     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3461     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3462
3463     state = 0xdeadbee;
3464     action = 0xdeadbee;
3465     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3466     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3467     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3468     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3469
3470     state = 0xdeadbee;
3471     action = 0xdeadbee;
3472     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3473     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3474     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3475     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3476
3477     state = 0xdeadbee;
3478     action = 0xdeadbee;
3479     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3480     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3481     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3482     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3483
3484     state = 0xdeadbee;
3485     action = 0xdeadbee;
3486     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3487     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3488     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3489     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3490
3491     state = 0xdeadbee;
3492     action = 0xdeadbee;
3493     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3494     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3495     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3496     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3497
3498     state = 0xdeadbee;
3499     action = 0xdeadbee;
3500     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3501     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3502     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3503     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3504
3505     state = 0xdeadbee;
3506     action = 0xdeadbee;
3507     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3508     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3509     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3510     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3511
3512     state = 0xdeadbee;
3513     action = 0xdeadbee;
3514     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3515     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3516     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3517     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3518
3519     MsiCloseHandle( hpkg );
3520
3521     /* publish the features and components */
3522     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3523     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3524
3525     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3526     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3527
3528     /* these properties must not be in the saved msi file */
3529     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3530     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3531
3532     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3533     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3534
3535     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3536     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3537
3538     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3539     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3540
3541     hpkg = package_from_db( hdb );
3542     ok( hpkg, "failed to create package\n");
3543
3544     MsiCloseHandle(hdb);
3545
3546     state = 0xdeadbee;
3547     action = 0xdeadbee;
3548     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3549     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3550     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3551     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3552
3553     state = 0xdeadbee;
3554     action = 0xdeadbee;
3555     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3556     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3557     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3558     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3559
3560     state = 0xdeadbee;
3561     action = 0xdeadbee;
3562     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3563     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3564     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3565     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3566
3567     state = 0xdeadbee;
3568     action = 0xdeadbee;
3569     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3570     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3571     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3572     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3573
3574     state = 0xdeadbee;
3575     action = 0xdeadbee;
3576     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3577     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3578     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3579     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3580
3581     state = 0xdeadbee;
3582     action = 0xdeadbee;
3583     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3584     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3585     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3586     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3587
3588     state = 0xdeadbee;
3589     action = 0xdeadbee;
3590     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3591     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3592     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3593     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3594
3595     state = 0xdeadbee;
3596     action = 0xdeadbee;
3597     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3598     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3599     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3600     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3601
3602     state = 0xdeadbee;
3603     action = 0xdeadbee;
3604     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3605     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3606     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3607     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3608
3609     state = 0xdeadbee;
3610     action = 0xdeadbee;
3611     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3612     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3613     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3614     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3615
3616     state = 0xdeadbee;
3617     action = 0xdeadbee;
3618     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3619     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3620     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3621     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3622
3623     state = 0xdeadbee;
3624     action = 0xdeadbee;
3625     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3626     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3627     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3628     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3629
3630     state = 0xdeadbee;
3631     action = 0xdeadbee;
3632     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3633     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3634     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3635     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3636
3637     state = 0xdeadbee;
3638     action = 0xdeadbee;
3639     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3640     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3641     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3642     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3643
3644     state = 0xdeadbee;
3645     action = 0xdeadbee;
3646     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3647     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3648     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3649     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3650
3651     state = 0xdeadbee;
3652     action = 0xdeadbee;
3653     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3654     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3655     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3656     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3657
3658     state = 0xdeadbee;
3659     action = 0xdeadbee;
3660     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3661     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3662     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3663     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3664
3665     state = 0xdeadbee;
3666     action = 0xdeadbee;
3667     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3668     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3669     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3670     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3671
3672     state = 0xdeadbee;
3673     action = 0xdeadbee;
3674     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3675     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3676     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3677     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3678
3679     state = 0xdeadbee;
3680     action = 0xdeadbee;
3681     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3682     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3683     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3684     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3685
3686     state = 0xdeadbee;
3687     action = 0xdeadbee;
3688     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3689     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3690     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3691     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3692
3693     state = 0xdeadbee;
3694     action = 0xdeadbee;
3695     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3696     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3697     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3698     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3699
3700     state = 0xdeadbee;
3701     action = 0xdeadbee;
3702     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3703     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3704     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3705     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3706
3707     state = 0xdeadbee;
3708     action = 0xdeadbee;
3709     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3710     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3711     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3712     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3713
3714     state = 0xdeadbee;
3715     action = 0xdeadbee;
3716     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3717     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3718     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3719     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3720
3721     state = 0xdeadbee;
3722     action = 0xdeadbee;
3723     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3724     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3725     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3726     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3727
3728     state = 0xdeadbee;
3729     action = 0xdeadbee;
3730     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3731     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3732     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3733     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3734
3735     state = 0xdeadbee;
3736     action = 0xdeadbee;
3737     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3738     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3739     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3740     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3741
3742     state = 0xdeadbee;
3743     action = 0xdeadbee;
3744     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3745     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3746     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3747     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3748
3749     state = 0xdeadbee;
3750     action = 0xdeadbee;
3751     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3752     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3753     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3754     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3755
3756     state = 0xdeadbee;
3757     action = 0xdeadbee;
3758     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3759     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3760     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3761     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3762
3763     r = MsiDoAction( hpkg, "CostInitialize");
3764     ok( r == ERROR_SUCCESS, "cost init failed\n");
3765
3766     state = 0xdeadbee;
3767     action = 0xdeadbee;
3768     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3769     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3770     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3771     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3772
3773     state = 0xdeadbee;
3774     action = 0xdeadbee;
3775     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3776     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3777     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3778     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3779
3780     state = 0xdeadbee;
3781     action = 0xdeadbee;
3782     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3783     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3784     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3785     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3786
3787     state = 0xdeadbee;
3788     action = 0xdeadbee;
3789     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3790     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3791     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3792     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3793
3794     state = 0xdeadbee;
3795     action = 0xdeadbee;
3796     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3797     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3798     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3799     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3800
3801     state = 0xdeadbee;
3802     action = 0xdeadbee;
3803     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3804     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3805     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3806     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3807
3808     state = 0xdeadbee;
3809     action = 0xdeadbee;
3810     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3811     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3812     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3813     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3814
3815     state = 0xdeadbee;
3816     action = 0xdeadbee;
3817     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3818     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3819     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3820     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3821
3822     state = 0xdeadbee;
3823     action = 0xdeadbee;
3824     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3825     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3826     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3827     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3828
3829     state = 0xdeadbee;
3830     action = 0xdeadbee;
3831     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3832     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3833     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3834     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3835
3836     state = 0xdeadbee;
3837     action = 0xdeadbee;
3838     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3839     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3840     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3841     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3842
3843     state = 0xdeadbee;
3844     action = 0xdeadbee;
3845     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3846     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3847     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3848     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3849
3850     state = 0xdeadbee;
3851     action = 0xdeadbee;
3852     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3853     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3854     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3855     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3856
3857     state = 0xdeadbee;
3858     action = 0xdeadbee;
3859     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3860     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3861     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3862     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3863
3864     state = 0xdeadbee;
3865     action = 0xdeadbee;
3866     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3867     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3868     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3869     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3870
3871     state = 0xdeadbee;
3872     action = 0xdeadbee;
3873     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3874     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3875     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3876     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3877
3878     state = 0xdeadbee;
3879     action = 0xdeadbee;
3880     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3881     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3882     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3883     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3884
3885     state = 0xdeadbee;
3886     action = 0xdeadbee;
3887     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3888     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3889     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3890     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3891
3892     state = 0xdeadbee;
3893     action = 0xdeadbee;
3894     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3895     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3896     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3897     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3898
3899     state = 0xdeadbee;
3900     action = 0xdeadbee;
3901     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3902     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3903     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3904     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3905
3906     state = 0xdeadbee;
3907     action = 0xdeadbee;
3908     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3909     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3910     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3911     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3912
3913     state = 0xdeadbee;
3914     action = 0xdeadbee;
3915     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3916     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3917     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3918     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3919
3920     state = 0xdeadbee;
3921     action = 0xdeadbee;
3922     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3923     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3924     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3925     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3926
3927     state = 0xdeadbee;
3928     action = 0xdeadbee;
3929     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3930     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3931     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3932     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3933
3934     state = 0xdeadbee;
3935     action = 0xdeadbee;
3936     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3937     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3938     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3939     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3940
3941     state = 0xdeadbee;
3942     action = 0xdeadbee;
3943     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3944     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3945     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3946     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3947
3948     state = 0xdeadbee;
3949     action = 0xdeadbee;
3950     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3951     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3952     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3953     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3954
3955     state = 0xdeadbee;
3956     action = 0xdeadbee;
3957     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3958     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3959     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3960     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3961
3962     state = 0xdeadbee;
3963     action = 0xdeadbee;
3964     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3965     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3966     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3967     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3968
3969     state = 0xdeadbee;
3970     action = 0xdeadbee;
3971     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3972     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3973     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3974     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3975
3976     state = 0xdeadbee;
3977     action = 0xdeadbee;
3978     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3979     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3980     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3981     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3982
3983     r = MsiDoAction( hpkg, "FileCost");
3984     ok( r == ERROR_SUCCESS, "file cost failed\n");
3985
3986     state = 0xdeadbee;
3987     action = 0xdeadbee;
3988     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3989     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3990     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3991     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3992
3993     state = 0xdeadbee;
3994     action = 0xdeadbee;
3995     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3996     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3997     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3998     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3999
4000     state = 0xdeadbee;
4001     action = 0xdeadbee;
4002     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4003     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4004     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4005     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4006
4007     state = 0xdeadbee;
4008     action = 0xdeadbee;
4009     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4010     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4011     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4012     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4013
4014     state = 0xdeadbee;
4015     action = 0xdeadbee;
4016     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4017     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4018     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4019     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4020
4021     state = 0xdeadbee;
4022     action = 0xdeadbee;
4023     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4024     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4025     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4026     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4027
4028     state = 0xdeadbee;
4029     action = 0xdeadbee;
4030     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4031     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4032     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4033     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4034
4035     state = 0xdeadbee;
4036     action = 0xdeadbee;
4037     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4038     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4039     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4040     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4041
4042     state = 0xdeadbee;
4043     action = 0xdeadbee;
4044     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4045     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4046     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4047     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4048
4049     state = 0xdeadbee;
4050     action = 0xdeadbee;
4051     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4052     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4053     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4054     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4055
4056     state = 0xdeadbee;
4057     action = 0xdeadbee;
4058     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4059     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4060     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4061     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4062
4063     state = 0xdeadbee;
4064     action = 0xdeadbee;
4065     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4066     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4067     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4068     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4069
4070     state = 0xdeadbee;
4071     action = 0xdeadbee;
4072     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4073     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4074     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4075     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4076
4077     state = 0xdeadbee;
4078     action = 0xdeadbee;
4079     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4080     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4081     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4082     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4083
4084     state = 0xdeadbee;
4085     action = 0xdeadbee;
4086     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4087     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4088     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4089     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4090
4091     state = 0xdeadbee;
4092     action = 0xdeadbee;
4093     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4094     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4095     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4096     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4097
4098     state = 0xdeadbee;
4099     action = 0xdeadbee;
4100     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4101     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4102     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4103     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4104
4105     state = 0xdeadbee;
4106     action = 0xdeadbee;
4107     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4108     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4109     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4110     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4111
4112     state = 0xdeadbee;
4113     action = 0xdeadbee;
4114     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4115     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4116     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4117     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4118
4119     state = 0xdeadbee;
4120     action = 0xdeadbee;
4121     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4122     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4123     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4124     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4125
4126     state = 0xdeadbee;
4127     action = 0xdeadbee;
4128     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4129     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4130     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4131     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4132
4133     state = 0xdeadbee;
4134     action = 0xdeadbee;
4135     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4136     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4137     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4138     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4139
4140     state = 0xdeadbee;
4141     action = 0xdeadbee;
4142     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4143     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4144     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4145     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4146
4147     state = 0xdeadbee;
4148     action = 0xdeadbee;
4149     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4150     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4151     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4152     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4153
4154     state = 0xdeadbee;
4155     action = 0xdeadbee;
4156     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4157     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4158     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4159     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4160
4161     state = 0xdeadbee;
4162     action = 0xdeadbee;
4163     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4164     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4165     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4166     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4167
4168     state = 0xdeadbee;
4169     action = 0xdeadbee;
4170     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4171     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4172     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4173     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4174
4175     state = 0xdeadbee;
4176     action = 0xdeadbee;
4177     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4178     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4179     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4180     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4181
4182     state = 0xdeadbee;
4183     action = 0xdeadbee;
4184     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4185     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4186     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4187     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4188
4189     state = 0xdeadbee;
4190     action = 0xdeadbee;
4191     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4192     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4193     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4194     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4195
4196     r = MsiDoAction( hpkg, "CostFinalize");
4197     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4198
4199     state = 0xdeadbee;
4200     action = 0xdeadbee;
4201     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4202     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4203     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4204     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4205
4206     state = 0xdeadbee;
4207     action = 0xdeadbee;
4208     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4209     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4210     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4211     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4212
4213     state = 0xdeadbee;
4214     action = 0xdeadbee;
4215     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4216     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4217     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4218     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4219
4220     state = 0xdeadbee;
4221     action = 0xdeadbee;
4222     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4223     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4224     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4225     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4226
4227     state = 0xdeadbee;
4228     action = 0xdeadbee;
4229     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4230     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4231     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4232     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4233
4234     state = 0xdeadbee;
4235     action = 0xdeadbee;
4236     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4237     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4238     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4239     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4240
4241     state = 0xdeadbee;
4242     action = 0xdeadbee;
4243     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4244     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4245     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4246     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4247
4248     state = 0xdeadbee;
4249     action = 0xdeadbee;
4250     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4251     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4252     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4253     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4254
4255     state = 0xdeadbee;
4256     action = 0xdeadbee;
4257     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4258     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4259     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4260     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4261
4262     state = 0xdeadbee;
4263     action = 0xdeadbee;
4264     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4265     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4266     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4267     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4268
4269     state = 0xdeadbee;
4270     action = 0xdeadbee;
4271     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4272     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4273     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4274     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4275
4276     state = 0xdeadbee;
4277     action = 0xdeadbee;
4278     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4279     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4280     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4281     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4282
4283     state = 0xdeadbee;
4284     action = 0xdeadbee;
4285     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4286     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4287     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4288     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4289
4290     state = 0xdeadbee;
4291     action = 0xdeadbee;
4292     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4293     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4294     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4295     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4296
4297     state = 0xdeadbee;
4298     action = 0xdeadbee;
4299     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4300     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4301     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4302     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4303
4304     state = 0xdeadbee;
4305     action = 0xdeadbee;
4306     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4307     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4308     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4309     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4310
4311     state = 0xdeadbee;
4312     action = 0xdeadbee;
4313     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4314     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4315     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4316     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4317
4318     state = 0xdeadbee;
4319     action = 0xdeadbee;
4320     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4321     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4322     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4323     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4324
4325     state = 0xdeadbee;
4326     action = 0xdeadbee;
4327     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4328     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4329     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4330     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4331
4332     state = 0xdeadbee;
4333     action = 0xdeadbee;
4334     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4335     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4336     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4337     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4338
4339     state = 0xdeadbee;
4340     action = 0xdeadbee;
4341     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4342     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4343     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4344     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4345
4346     state = 0xdeadbee;
4347     action = 0xdeadbee;
4348     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4349     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4350     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4351     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4352
4353     state = 0xdeadbee;
4354     action = 0xdeadbee;
4355     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4356     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4357     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4358     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4359
4360     state = 0xdeadbee;
4361     action = 0xdeadbee;
4362     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4363     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4364     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4365     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4366
4367     state = 0xdeadbee;
4368     action = 0xdeadbee;
4369     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4370     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4371     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4372     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4373
4374     state = 0xdeadbee;
4375     action = 0xdeadbee;
4376     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4377     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4378     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4379     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4380
4381     state = 0xdeadbee;
4382     action = 0xdeadbee;
4383     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4384     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4385     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4386     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4387
4388     state = 0xdeadbee;
4389     action = 0xdeadbee;
4390     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4391     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4392     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4393     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4394
4395     state = 0xdeadbee;
4396     action = 0xdeadbee;
4397     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4398     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4399     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4400     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4401
4402     state = 0xdeadbee;
4403     action = 0xdeadbee;
4404     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4405     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4406     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4407     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4408
4409     state = 0xdeadbee;
4410     action = 0xdeadbee;
4411     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4412     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4413     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4414     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4415
4416     MsiCloseHandle(hpkg);
4417
4418     /* uninstall the product */
4419     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4420     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4421
4422     /* all features installed locally */
4423     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4425
4426     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4427     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4428
4429     /* these properties must not be in the saved msi file */
4430     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4431     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4432
4433     hpkg = package_from_db( hdb );
4434     ok( hpkg, "failed to create package\n");
4435
4436     state = 0xdeadbee;
4437     action = 0xdeadbee;
4438     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4439     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4440     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4441     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4442
4443     state = 0xdeadbee;
4444     action = 0xdeadbee;
4445     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4446     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4447     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4448     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4449
4450     state = 0xdeadbee;
4451     action = 0xdeadbee;
4452     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4453     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4454     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4455     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4456
4457     state = 0xdeadbee;
4458     action = 0xdeadbee;
4459     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4460     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4461     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4462     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4463
4464     state = 0xdeadbee;
4465     action = 0xdeadbee;
4466     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4467     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4468     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4469     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4470
4471     state = 0xdeadbee;
4472     action = 0xdeadbee;
4473     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4474     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4475     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4476     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4477
4478     state = 0xdeadbee;
4479     action = 0xdeadbee;
4480     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4481     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4482     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4483     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4484
4485     state = 0xdeadbee;
4486     action = 0xdeadbee;
4487     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4488     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4489     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4490     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4491
4492     state = 0xdeadbee;
4493     action = 0xdeadbee;
4494     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4495     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4496     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4497     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4498
4499     state = 0xdeadbee;
4500     action = 0xdeadbee;
4501     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4502     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4503     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4504     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4505
4506     state = 0xdeadbee;
4507     action = 0xdeadbee;
4508     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4509     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4510     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4511     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4512
4513     state = 0xdeadbee;
4514     action = 0xdeadbee;
4515     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4516     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4517     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4518     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4519
4520     state = 0xdeadbee;
4521     action = 0xdeadbee;
4522     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4523     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4524     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4525     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4526
4527     state = 0xdeadbee;
4528     action = 0xdeadbee;
4529     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4530     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4531     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4532     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4533
4534     state = 0xdeadbee;
4535     action = 0xdeadbee;
4536     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4537     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4538     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4539     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4540
4541     state = 0xdeadbee;
4542     action = 0xdeadbee;
4543     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4544     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4545     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4546     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4547
4548     state = 0xdeadbee;
4549     action = 0xdeadbee;
4550     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4551     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4552     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4553     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4554
4555     state = 0xdeadbee;
4556     action = 0xdeadbee;
4557     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4558     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4559     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4560     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4561
4562     state = 0xdeadbee;
4563     action = 0xdeadbee;
4564     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4565     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4566     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4567     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4568
4569     state = 0xdeadbee;
4570     action = 0xdeadbee;
4571     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4572     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4573     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4574     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4575
4576     state = 0xdeadbee;
4577     action = 0xdeadbee;
4578     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4579     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4580     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4581     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4582
4583     state = 0xdeadbee;
4584     action = 0xdeadbee;
4585     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4586     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4587     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4588     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4589
4590     state = 0xdeadbee;
4591     action = 0xdeadbee;
4592     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4593     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4594     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4595     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4596
4597     state = 0xdeadbee;
4598     action = 0xdeadbee;
4599     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4600     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4601     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4602     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4603
4604     state = 0xdeadbee;
4605     action = 0xdeadbee;
4606     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4607     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4608     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4609     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4610
4611     state = 0xdeadbee;
4612     action = 0xdeadbee;
4613     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4614     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4615     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4616     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4617
4618     state = 0xdeadbee;
4619     action = 0xdeadbee;
4620     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4621     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4622     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4623     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4624
4625     state = 0xdeadbee;
4626     action = 0xdeadbee;
4627     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4628     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4629     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4630     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4631
4632     state = 0xdeadbee;
4633     action = 0xdeadbee;
4634     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4635     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4636     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4637     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4638
4639     state = 0xdeadbee;
4640     action = 0xdeadbee;
4641     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4642     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4643     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4644     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4645
4646     state = 0xdeadbee;
4647     action = 0xdeadbee;
4648     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4649     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4650     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4651     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4652
4653     r = MsiDoAction( hpkg, "CostInitialize");
4654     ok( r == ERROR_SUCCESS, "cost init failed\n");
4655
4656     state = 0xdeadbee;
4657     action = 0xdeadbee;
4658     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4660     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4661     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4662
4663     state = 0xdeadbee;
4664     action = 0xdeadbee;
4665     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4667     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4668     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4669
4670     state = 0xdeadbee;
4671     action = 0xdeadbee;
4672     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4674     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4675     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4676
4677     state = 0xdeadbee;
4678     action = 0xdeadbee;
4679     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4681     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4682     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4683
4684     state = 0xdeadbee;
4685     action = 0xdeadbee;
4686     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4688     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4689     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4690
4691     state = 0xdeadbee;
4692     action = 0xdeadbee;
4693     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4695     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4696     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4697
4698     state = 0xdeadbee;
4699     action = 0xdeadbee;
4700     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4701     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4702     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4703     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4704
4705     state = 0xdeadbee;
4706     action = 0xdeadbee;
4707     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4708     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4709     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4710     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4711
4712     state = 0xdeadbee;
4713     action = 0xdeadbee;
4714     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4715     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4716     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4717     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4718
4719     state = 0xdeadbee;
4720     action = 0xdeadbee;
4721     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4722     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4723     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4724     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4725
4726     state = 0xdeadbee;
4727     action = 0xdeadbee;
4728     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4729     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4730     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4731     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4732
4733     state = 0xdeadbee;
4734     action = 0xdeadbee;
4735     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4736     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4737     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4738     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4739
4740     state = 0xdeadbee;
4741     action = 0xdeadbee;
4742     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4743     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4744     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4745     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4746
4747     state = 0xdeadbee;
4748     action = 0xdeadbee;
4749     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4750     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4751     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4752     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4753
4754     state = 0xdeadbee;
4755     action = 0xdeadbee;
4756     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4757     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4758     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4759     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4760
4761     state = 0xdeadbee;
4762     action = 0xdeadbee;
4763     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4764     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4765     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4766     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4767
4768     state = 0xdeadbee;
4769     action = 0xdeadbee;
4770     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4771     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4772     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4773     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4774
4775     state = 0xdeadbee;
4776     action = 0xdeadbee;
4777     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4778     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4779     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4780     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4781
4782     state = 0xdeadbee;
4783     action = 0xdeadbee;
4784     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4785     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4786     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4787     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4788
4789     state = 0xdeadbee;
4790     action = 0xdeadbee;
4791     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4792     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4793     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4794     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4795
4796     state = 0xdeadbee;
4797     action = 0xdeadbee;
4798     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4799     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4800     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4801     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4802
4803     state = 0xdeadbee;
4804     action = 0xdeadbee;
4805     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4806     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4807     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4808     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4809
4810     state = 0xdeadbee;
4811     action = 0xdeadbee;
4812     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4813     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4814     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4815     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4816
4817     state = 0xdeadbee;
4818     action = 0xdeadbee;
4819     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4820     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4821     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4822     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4823
4824     state = 0xdeadbee;
4825     action = 0xdeadbee;
4826     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4827     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4828     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4829     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4830
4831     state = 0xdeadbee;
4832     action = 0xdeadbee;
4833     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4834     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4835     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4836     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4837
4838     state = 0xdeadbee;
4839     action = 0xdeadbee;
4840     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4841     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4842     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4843     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4844
4845     state = 0xdeadbee;
4846     action = 0xdeadbee;
4847     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4848     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4849     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4850     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4851
4852     state = 0xdeadbee;
4853     action = 0xdeadbee;
4854     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4855     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4856     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4857     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4858
4859     state = 0xdeadbee;
4860     action = 0xdeadbee;
4861     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4862     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4863     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4864     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4865
4866     state = 0xdeadbee;
4867     action = 0xdeadbee;
4868     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4869     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4870     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4871     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4872
4873     r = MsiDoAction( hpkg, "FileCost");
4874     ok( r == ERROR_SUCCESS, "file cost failed\n");
4875
4876     state = 0xdeadbee;
4877     action = 0xdeadbee;
4878     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4879     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4880     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4881     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4882
4883     state = 0xdeadbee;
4884     action = 0xdeadbee;
4885     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4886     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4887     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4888     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4889
4890     state = 0xdeadbee;
4891     action = 0xdeadbee;
4892     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4893     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4894     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4895     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4896
4897     state = 0xdeadbee;
4898     action = 0xdeadbee;
4899     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4900     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4901     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4902     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4903
4904     state = 0xdeadbee;
4905     action = 0xdeadbee;
4906     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4907     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4908     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4909     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4910
4911     state = 0xdeadbee;
4912     action = 0xdeadbee;
4913     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4914     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4915     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4916     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4917
4918     state = 0xdeadbee;
4919     action = 0xdeadbee;
4920     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4921     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4922     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4923     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4924
4925     state = 0xdeadbee;
4926     action = 0xdeadbee;
4927     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4928     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4929     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4930     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4931
4932     state = 0xdeadbee;
4933     action = 0xdeadbee;
4934     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4935     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4936     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4937     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4938
4939     state = 0xdeadbee;
4940     action = 0xdeadbee;
4941     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4942     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4943     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4944     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4945
4946     state = 0xdeadbee;
4947     action = 0xdeadbee;
4948     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4949     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4950     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4951     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4952
4953     state = 0xdeadbee;
4954     action = 0xdeadbee;
4955     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4956     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4957     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4958     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4959
4960     state = 0xdeadbee;
4961     action = 0xdeadbee;
4962     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4963     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4964     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4965     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4966
4967     state = 0xdeadbee;
4968     action = 0xdeadbee;
4969     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4970     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4971     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4972     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4973
4974     state = 0xdeadbee;
4975     action = 0xdeadbee;
4976     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4977     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4978     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4979     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4980
4981     state = 0xdeadbee;
4982     action = 0xdeadbee;
4983     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4984     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4985     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4986     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4987
4988     state = 0xdeadbee;
4989     action = 0xdeadbee;
4990     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4991     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4992     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4993     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4994
4995     state = 0xdeadbee;
4996     action = 0xdeadbee;
4997     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4998     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4999     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5000     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5001
5002     state = 0xdeadbee;
5003     action = 0xdeadbee;
5004     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5005     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5006     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5007     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5008
5009     state = 0xdeadbee;
5010     action = 0xdeadbee;
5011     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5012     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5013     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5014     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5015
5016     state = 0xdeadbee;
5017     action = 0xdeadbee;
5018     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5019     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5020     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5021     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5022
5023     state = 0xdeadbee;
5024     action = 0xdeadbee;
5025     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5026     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5027     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5028     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5029
5030     state = 0xdeadbee;
5031     action = 0xdeadbee;
5032     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5034     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5035     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5036
5037     state = 0xdeadbee;
5038     action = 0xdeadbee;
5039     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5040     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5041     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5042     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5043
5044     state = 0xdeadbee;
5045     action = 0xdeadbee;
5046     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5047     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5048     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5049     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5050
5051     state = 0xdeadbee;
5052     action = 0xdeadbee;
5053     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5055     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5056     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5057
5058     state = 0xdeadbee;
5059     action = 0xdeadbee;
5060     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5061     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5062     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5063     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5064
5065     state = 0xdeadbee;
5066     action = 0xdeadbee;
5067     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5068     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5069     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5070     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5071
5072     state = 0xdeadbee;
5073     action = 0xdeadbee;
5074     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5075     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5076     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5077     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5078
5079     state = 0xdeadbee;
5080     action = 0xdeadbee;
5081     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5082     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5083     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5084     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5085
5086     state = 0xdeadbee;
5087     action = 0xdeadbee;
5088     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5089     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5090     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5091     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5092
5093     r = MsiDoAction( hpkg, "CostFinalize");
5094     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5095
5096     state = 0xdeadbee;
5097     action = 0xdeadbee;
5098     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5100     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5101     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5102
5103     state = 0xdeadbee;
5104     action = 0xdeadbee;
5105     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5107     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5108     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5109
5110     state = 0xdeadbee;
5111     action = 0xdeadbee;
5112     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5114     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5115     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5116
5117     state = 0xdeadbee;
5118     action = 0xdeadbee;
5119     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5121     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5122     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5123
5124     state = 0xdeadbee;
5125     action = 0xdeadbee;
5126     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5128     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5129     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5130
5131     state = 0xdeadbee;
5132     action = 0xdeadbee;
5133     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5135     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5136     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5137
5138     state = 0xdeadbee;
5139     action = 0xdeadbee;
5140     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5142     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5143     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5144
5145     state = 0xdeadbee;
5146     action = 0xdeadbee;
5147     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5149     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5150     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5151
5152     state = 0xdeadbee;
5153     action = 0xdeadbee;
5154     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5156     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5157     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5158
5159     state = 0xdeadbee;
5160     action = 0xdeadbee;
5161     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5163     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5164     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5165
5166     state = 0xdeadbee;
5167     action = 0xdeadbee;
5168     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5170     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5171     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5172
5173     state = 0xdeadbee;
5174     action = 0xdeadbee;
5175     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5177     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5178     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5179
5180     state = 0xdeadbee;
5181     action = 0xdeadbee;
5182     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5184     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5185     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5186
5187     state = 0xdeadbee;
5188     action = 0xdeadbee;
5189     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5191     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5192     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5193
5194     state = 0xdeadbee;
5195     action = 0xdeadbee;
5196     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5197     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5198     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5199     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5200
5201     state = 0xdeadbee;
5202     action = 0xdeadbee;
5203     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5204     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5205     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5206     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5207
5208     state = 0xdeadbee;
5209     action = 0xdeadbee;
5210     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5211     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5212     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5213     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5214
5215     state = 0xdeadbee;
5216     action = 0xdeadbee;
5217     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5218     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5219     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5220     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5221
5222     state = 0xdeadbee;
5223     action = 0xdeadbee;
5224     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5225     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5226     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5227     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5228
5229     state = 0xdeadbee;
5230     action = 0xdeadbee;
5231     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5232     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5233     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5234     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5235
5236     state = 0xdeadbee;
5237     action = 0xdeadbee;
5238     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5239     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5240     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5241     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5242
5243     state = 0xdeadbee;
5244     action = 0xdeadbee;
5245     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5246     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5247     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5248     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5249
5250     state = 0xdeadbee;
5251     action = 0xdeadbee;
5252     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5253     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5254     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5255     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5256
5257     state = 0xdeadbee;
5258     action = 0xdeadbee;
5259     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5260     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5261     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5262     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5263
5264     state = 0xdeadbee;
5265     action = 0xdeadbee;
5266     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5267     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5268     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5269     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5270
5271     state = 0xdeadbee;
5272     action = 0xdeadbee;
5273     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5274     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5275     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5276     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5277
5278     state = 0xdeadbee;
5279     action = 0xdeadbee;
5280     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5281     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5282     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5283     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5284
5285     state = 0xdeadbee;
5286     action = 0xdeadbee;
5287     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5288     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5289     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5290     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5291
5292     state = 0xdeadbee;
5293     action = 0xdeadbee;
5294     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5295     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5296     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5297     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5298
5299     state = 0xdeadbee;
5300     action = 0xdeadbee;
5301     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5302     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5303     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5304     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5305
5306     state = 0xdeadbee;
5307     action = 0xdeadbee;
5308     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5309     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5310     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5311     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5312
5313     MsiCloseHandle(hpkg);
5314
5315     /* uninstall the product */
5316     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5317     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5318
5319     /* all features installed from source */
5320     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5321     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5322
5323     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5324     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5325
5326     /* this property must not be in the saved msi file */
5327     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5328     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5329
5330     hpkg = package_from_db( hdb );
5331     ok( hpkg, "failed to create package\n");
5332
5333     state = 0xdeadbee;
5334     action = 0xdeadbee;
5335     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5336     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5337     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5338     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5339
5340     state = 0xdeadbee;
5341     action = 0xdeadbee;
5342     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5343     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5344     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5345     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5346
5347     state = 0xdeadbee;
5348     action = 0xdeadbee;
5349     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5350     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5351     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5352     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5353
5354     state = 0xdeadbee;
5355     action = 0xdeadbee;
5356     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5357     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5358     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5359     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5360
5361     state = 0xdeadbee;
5362     action = 0xdeadbee;
5363     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5364     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5365     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5366     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5367
5368     state = 0xdeadbee;
5369     action = 0xdeadbee;
5370     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5371     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5372     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5373     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5374
5375     state = 0xdeadbee;
5376     action = 0xdeadbee;
5377     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5378     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5379     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5380     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5381
5382     state = 0xdeadbee;
5383     action = 0xdeadbee;
5384     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5385     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5386     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5387     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5388
5389     state = 0xdeadbee;
5390     action = 0xdeadbee;
5391     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5392     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5393     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5394     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5395
5396     state = 0xdeadbee;
5397     action = 0xdeadbee;
5398     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5399     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5400     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5401     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5402
5403     state = 0xdeadbee;
5404     action = 0xdeadbee;
5405     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5406     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5407     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5408     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5409
5410     state = 0xdeadbee;
5411     action = 0xdeadbee;
5412     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5413     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5414     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5415     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5416
5417     state = 0xdeadbee;
5418     action = 0xdeadbee;
5419     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5420     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5421     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5422     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5423
5424     state = 0xdeadbee;
5425     action = 0xdeadbee;
5426     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5427     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5428     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5429     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5430
5431     state = 0xdeadbee;
5432     action = 0xdeadbee;
5433     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5434     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5435     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5436     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5437
5438     state = 0xdeadbee;
5439     action = 0xdeadbee;
5440     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5441     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5442     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5443     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5444
5445     state = 0xdeadbee;
5446     action = 0xdeadbee;
5447     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5448     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5449     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5450     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5451
5452     state = 0xdeadbee;
5453     action = 0xdeadbee;
5454     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5455     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5456     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5457     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5458
5459     state = 0xdeadbee;
5460     action = 0xdeadbee;
5461     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5462     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5463     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5464     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5465
5466     state = 0xdeadbee;
5467     action = 0xdeadbee;
5468     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5469     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5470     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5471     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5472
5473     state = 0xdeadbee;
5474     action = 0xdeadbee;
5475     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5476     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5477     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5478     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5479
5480     state = 0xdeadbee;
5481     action = 0xdeadbee;
5482     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5483     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5484     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5485     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5486
5487     state = 0xdeadbee;
5488     action = 0xdeadbee;
5489     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5490     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5491     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5492     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5493
5494     state = 0xdeadbee;
5495     action = 0xdeadbee;
5496     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5497     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5498     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5499     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5500
5501     state = 0xdeadbee;
5502     action = 0xdeadbee;
5503     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5504     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5505     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5506     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5507
5508     state = 0xdeadbee;
5509     action = 0xdeadbee;
5510     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5511     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5512     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5513     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5514
5515     state = 0xdeadbee;
5516     action = 0xdeadbee;
5517     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5518     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5519     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5520     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5521
5522     state = 0xdeadbee;
5523     action = 0xdeadbee;
5524     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5525     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5526     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5527     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5528
5529     state = 0xdeadbee;
5530     action = 0xdeadbee;
5531     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5532     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5533     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5534     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5535
5536     state = 0xdeadbee;
5537     action = 0xdeadbee;
5538     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5539     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5540     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5541     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5542
5543     state = 0xdeadbee;
5544     action = 0xdeadbee;
5545     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5546     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5547     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5548     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5549
5550     r = MsiDoAction( hpkg, "CostInitialize");
5551     ok( r == ERROR_SUCCESS, "cost init failed\n");
5552
5553     state = 0xdeadbee;
5554     action = 0xdeadbee;
5555     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5556     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5557     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5558     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5559
5560     state = 0xdeadbee;
5561     action = 0xdeadbee;
5562     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5563     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5564     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5565     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5566
5567     state = 0xdeadbee;
5568     action = 0xdeadbee;
5569     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5570     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5571     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5572     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5573
5574     state = 0xdeadbee;
5575     action = 0xdeadbee;
5576     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5577     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5578     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5579     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5580
5581     state = 0xdeadbee;
5582     action = 0xdeadbee;
5583     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5584     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5585     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5586     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5587
5588     state = 0xdeadbee;
5589     action = 0xdeadbee;
5590     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5591     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5592     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5593     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5594
5595     state = 0xdeadbee;
5596     action = 0xdeadbee;
5597     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5598     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5599     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5600     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5601
5602     state = 0xdeadbee;
5603     action = 0xdeadbee;
5604     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5605     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5606     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5607     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5608
5609     state = 0xdeadbee;
5610     action = 0xdeadbee;
5611     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5612     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5613     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5614     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5615
5616     state = 0xdeadbee;
5617     action = 0xdeadbee;
5618     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5619     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5620     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5621     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5622
5623     state = 0xdeadbee;
5624     action = 0xdeadbee;
5625     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5626     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5627     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5628     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5629
5630     state = 0xdeadbee;
5631     action = 0xdeadbee;
5632     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5633     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5634     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5635     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5636
5637     state = 0xdeadbee;
5638     action = 0xdeadbee;
5639     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5640     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5641     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5642     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5643
5644     state = 0xdeadbee;
5645     action = 0xdeadbee;
5646     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5647     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5648     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5649     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5650
5651     state = 0xdeadbee;
5652     action = 0xdeadbee;
5653     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5654     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5655     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5656     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5657
5658     state = 0xdeadbee;
5659     action = 0xdeadbee;
5660     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5661     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5662     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5663     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5664
5665     state = 0xdeadbee;
5666     action = 0xdeadbee;
5667     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5668     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5669     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5670     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5671
5672     state = 0xdeadbee;
5673     action = 0xdeadbee;
5674     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5675     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5676     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5677     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5678
5679     state = 0xdeadbee;
5680     action = 0xdeadbee;
5681     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5682     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5683     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5684     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5685
5686     state = 0xdeadbee;
5687     action = 0xdeadbee;
5688     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5689     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5690     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5691     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5692
5693     state = 0xdeadbee;
5694     action = 0xdeadbee;
5695     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5696     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5697     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5698     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5699
5700     state = 0xdeadbee;
5701     action = 0xdeadbee;
5702     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5703     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5704     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5705     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5706
5707     state = 0xdeadbee;
5708     action = 0xdeadbee;
5709     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5710     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5711     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5712     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5713
5714     state = 0xdeadbee;
5715     action = 0xdeadbee;
5716     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5717     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5718     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5719     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5720
5721     state = 0xdeadbee;
5722     action = 0xdeadbee;
5723     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5724     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5725     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5726     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5727
5728     state = 0xdeadbee;
5729     action = 0xdeadbee;
5730     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5731     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5732     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5733     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5734
5735     state = 0xdeadbee;
5736     action = 0xdeadbee;
5737     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5738     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5739     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5740     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5741
5742     state = 0xdeadbee;
5743     action = 0xdeadbee;
5744     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5745     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5746     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5747     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5748
5749     state = 0xdeadbee;
5750     action = 0xdeadbee;
5751     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5752     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5753     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5754     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5755
5756     state = 0xdeadbee;
5757     action = 0xdeadbee;
5758     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5759     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5760     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5761     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5762
5763     state = 0xdeadbee;
5764     action = 0xdeadbee;
5765     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5766     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5767     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5768     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5769
5770     r = MsiDoAction( hpkg, "FileCost");
5771     ok( r == ERROR_SUCCESS, "file cost failed\n");
5772
5773     state = 0xdeadbee;
5774     action = 0xdeadbee;
5775     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5776     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5777     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5778     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5779
5780     state = 0xdeadbee;
5781     action = 0xdeadbee;
5782     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5783     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5784     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5785     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5786
5787     state = 0xdeadbee;
5788     action = 0xdeadbee;
5789     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5790     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5791     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5792     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5793
5794     state = 0xdeadbee;
5795     action = 0xdeadbee;
5796     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5797     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5798     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5799     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5800
5801     state = 0xdeadbee;
5802     action = 0xdeadbee;
5803     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5804     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5805     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5806     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5807
5808     state = 0xdeadbee;
5809     action = 0xdeadbee;
5810     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5811     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5812     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5813     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5814
5815     state = 0xdeadbee;
5816     action = 0xdeadbee;
5817     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5818     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5819     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5820     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5821
5822     state = 0xdeadbee;
5823     action = 0xdeadbee;
5824     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5825     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5826     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5827     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5828
5829     state = 0xdeadbee;
5830     action = 0xdeadbee;
5831     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5832     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5833     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5834     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5835
5836     state = 0xdeadbee;
5837     action = 0xdeadbee;
5838     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5839     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5840     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5841     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5842
5843     state = 0xdeadbee;
5844     action = 0xdeadbee;
5845     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5846     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5847     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5848     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5849
5850     state = 0xdeadbee;
5851     action = 0xdeadbee;
5852     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5853     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5854     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5855     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5856
5857     state = 0xdeadbee;
5858     action = 0xdeadbee;
5859     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5860     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5861     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5862     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5863
5864     state = 0xdeadbee;
5865     action = 0xdeadbee;
5866     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5867     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5868     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5869     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5870
5871     state = 0xdeadbee;
5872     action = 0xdeadbee;
5873     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5874     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5875     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5876     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5877
5878     state = 0xdeadbee;
5879     action = 0xdeadbee;
5880     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5881     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5882     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5883     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5884
5885     state = 0xdeadbee;
5886     action = 0xdeadbee;
5887     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5888     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5889     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5890     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5891
5892     state = 0xdeadbee;
5893     action = 0xdeadbee;
5894     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5895     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5896     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5897     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5898
5899     state = 0xdeadbee;
5900     action = 0xdeadbee;
5901     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5902     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5903     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5904     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5905
5906     state = 0xdeadbee;
5907     action = 0xdeadbee;
5908     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5909     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5910     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5911     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5912
5913     state = 0xdeadbee;
5914     action = 0xdeadbee;
5915     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5916     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5917     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5918     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5919
5920     state = 0xdeadbee;
5921     action = 0xdeadbee;
5922     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5923     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5924     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5925     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5926
5927     state = 0xdeadbee;
5928     action = 0xdeadbee;
5929     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5930     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5931     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5932     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5933
5934     state = 0xdeadbee;
5935     action = 0xdeadbee;
5936     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5937     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5938     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5939     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5940
5941     state = 0xdeadbee;
5942     action = 0xdeadbee;
5943     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5944     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5945     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5946     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5947
5948     state = 0xdeadbee;
5949     action = 0xdeadbee;
5950     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5951     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5952     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5953     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5954
5955     state = 0xdeadbee;
5956     action = 0xdeadbee;
5957     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5958     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5959     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5960     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5961
5962     state = 0xdeadbee;
5963     action = 0xdeadbee;
5964     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5965     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5966     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5967     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5968
5969     state = 0xdeadbee;
5970     action = 0xdeadbee;
5971     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5972     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5973     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5974     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5975
5976     state = 0xdeadbee;
5977     action = 0xdeadbee;
5978     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5979     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5980     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5981     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5982
5983     state = 0xdeadbee;
5984     action = 0xdeadbee;
5985     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5986     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5987     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5988     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5989
5990     r = MsiDoAction( hpkg, "CostFinalize");
5991     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5992
5993     state = 0xdeadbee;
5994     action = 0xdeadbee;
5995     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5996     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5997     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5998     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5999
6000     state = 0xdeadbee;
6001     action = 0xdeadbee;
6002     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6003     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6004     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6005     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6006
6007     state = 0xdeadbee;
6008     action = 0xdeadbee;
6009     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6010     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6011     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6012     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6013
6014     state = 0xdeadbee;
6015     action = 0xdeadbee;
6016     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6017     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6018     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6019     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6020
6021     state = 0xdeadbee;
6022     action = 0xdeadbee;
6023     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6024     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6025     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6026     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6027
6028     state = 0xdeadbee;
6029     action = 0xdeadbee;
6030     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6031     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6032     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6033     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6034
6035     state = 0xdeadbee;
6036     action = 0xdeadbee;
6037     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6038     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6039     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6040     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6041
6042     state = 0xdeadbee;
6043     action = 0xdeadbee;
6044     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6045     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6046     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6047     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6048
6049     state = 0xdeadbee;
6050     action = 0xdeadbee;
6051     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6052     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6053     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6054     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6055
6056     state = 0xdeadbee;
6057     action = 0xdeadbee;
6058     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6059     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6060     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6061     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6062
6063     state = 0xdeadbee;
6064     action = 0xdeadbee;
6065     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6066     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6067     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6068     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6069
6070     state = 0xdeadbee;
6071     action = 0xdeadbee;
6072     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6073     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6074     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6075     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6076
6077     state = 0xdeadbee;
6078     action = 0xdeadbee;
6079     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6080     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6081     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6082     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6083
6084     state = 0xdeadbee;
6085     action = 0xdeadbee;
6086     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6087     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6088     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6089     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6090
6091     state = 0xdeadbee;
6092     action = 0xdeadbee;
6093     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6094     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6095     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6096     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6097
6098     state = 0xdeadbee;
6099     action = 0xdeadbee;
6100     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6101     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6102     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6103     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6104
6105     state = 0xdeadbee;
6106     action = 0xdeadbee;
6107     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6108     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6109     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6110     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6111
6112     state = 0xdeadbee;
6113     action = 0xdeadbee;
6114     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6115     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6116     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6117     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6118
6119     state = 0xdeadbee;
6120     action = 0xdeadbee;
6121     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6122     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6123     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6124     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6125
6126     state = 0xdeadbee;
6127     action = 0xdeadbee;
6128     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6129     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6130     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6131     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6132
6133     state = 0xdeadbee;
6134     action = 0xdeadbee;
6135     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6136     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6137     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6138     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6139
6140     state = 0xdeadbee;
6141     action = 0xdeadbee;
6142     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6143     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6144     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6145     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6146
6147     state = 0xdeadbee;
6148     action = 0xdeadbee;
6149     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6150     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6151     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6152     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6153
6154     state = 0xdeadbee;
6155     action = 0xdeadbee;
6156     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6157     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6158     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6159     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6160
6161     state = 0xdeadbee;
6162     action = 0xdeadbee;
6163     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6164     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6165     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6166     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6167
6168     state = 0xdeadbee;
6169     action = 0xdeadbee;
6170     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6171     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6172     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6173     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6174
6175     state = 0xdeadbee;
6176     action = 0xdeadbee;
6177     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6178     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6179     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6180     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6181
6182     state = 0xdeadbee;
6183     action = 0xdeadbee;
6184     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6185     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6186     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6187     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6188
6189     state = 0xdeadbee;
6190     action = 0xdeadbee;
6191     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6192     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6193     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6194     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6195
6196     state = 0xdeadbee;
6197     action = 0xdeadbee;
6198     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6199     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6200     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6201     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6202
6203     state = 0xdeadbee;
6204     action = 0xdeadbee;
6205     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6206     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6207     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6208     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6209
6210     MsiCloseHandle(hpkg);
6211
6212     /* reinstall the product */
6213     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6214     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6215
6216     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6217     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6218
6219     /* this property must not be in the saved msi file */
6220     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6221     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6222
6223     hpkg = package_from_db( hdb );
6224     ok( hpkg, "failed to create package\n");
6225
6226     state = 0xdeadbee;
6227     action = 0xdeadbee;
6228     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6229     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6230     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6231     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6232
6233     state = 0xdeadbee;
6234     action = 0xdeadbee;
6235     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6236     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6237     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6238     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6239
6240     state = 0xdeadbee;
6241     action = 0xdeadbee;
6242     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6243     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6244     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6245     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6246
6247     state = 0xdeadbee;
6248     action = 0xdeadbee;
6249     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6250     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6251     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6252     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6253
6254     state = 0xdeadbee;
6255     action = 0xdeadbee;
6256     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6257     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6258     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6259     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6260
6261     state = 0xdeadbee;
6262     action = 0xdeadbee;
6263     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6264     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6265     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6266     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6267
6268     state = 0xdeadbee;
6269     action = 0xdeadbee;
6270     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6271     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6272     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6273     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6274
6275     state = 0xdeadbee;
6276     action = 0xdeadbee;
6277     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6278     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6279     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6280     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6281
6282     state = 0xdeadbee;
6283     action = 0xdeadbee;
6284     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6285     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6286     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6287     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6288
6289     state = 0xdeadbee;
6290     action = 0xdeadbee;
6291     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6292     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6293     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6294     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6295
6296     state = 0xdeadbee;
6297     action = 0xdeadbee;
6298     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6299     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6300     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6301     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6302
6303     state = 0xdeadbee;
6304     action = 0xdeadbee;
6305     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6306     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6307     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6308     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6309
6310     state = 0xdeadbee;
6311     action = 0xdeadbee;
6312     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6313     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6314     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6315     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6316
6317     state = 0xdeadbee;
6318     action = 0xdeadbee;
6319     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6320     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6321     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6322     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6323
6324     state = 0xdeadbee;
6325     action = 0xdeadbee;
6326     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6327     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6328     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6329     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6330
6331     state = 0xdeadbee;
6332     action = 0xdeadbee;
6333     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6334     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6335     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6336     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6337
6338     state = 0xdeadbee;
6339     action = 0xdeadbee;
6340     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6341     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6342     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6343     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6344
6345     state = 0xdeadbee;
6346     action = 0xdeadbee;
6347     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6348     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6349     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6350     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6351
6352     state = 0xdeadbee;
6353     action = 0xdeadbee;
6354     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6355     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6356     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6357     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6358
6359     state = 0xdeadbee;
6360     action = 0xdeadbee;
6361     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6362     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6363     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6364     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6365
6366     state = 0xdeadbee;
6367     action = 0xdeadbee;
6368     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6369     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6370     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6371     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6372
6373     state = 0xdeadbee;
6374     action = 0xdeadbee;
6375     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6376     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6377     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6378     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6379
6380     state = 0xdeadbee;
6381     action = 0xdeadbee;
6382     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6383     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6384     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6385     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6386
6387     state = 0xdeadbee;
6388     action = 0xdeadbee;
6389     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6390     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6391     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6392     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6393
6394     state = 0xdeadbee;
6395     action = 0xdeadbee;
6396     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6397     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6398     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6399     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6400
6401     state = 0xdeadbee;
6402     action = 0xdeadbee;
6403     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6404     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6405     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6406     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6407
6408     state = 0xdeadbee;
6409     action = 0xdeadbee;
6410     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6411     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6412     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6413     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6414
6415     state = 0xdeadbee;
6416     action = 0xdeadbee;
6417     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6418     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6419     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6420     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6421
6422     state = 0xdeadbee;
6423     action = 0xdeadbee;
6424     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6425     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6426     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6427     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6428
6429     state = 0xdeadbee;
6430     action = 0xdeadbee;
6431     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6432     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6433     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6434     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6435
6436     state = 0xdeadbee;
6437     action = 0xdeadbee;
6438     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6439     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6440     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6441     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6442
6443     r = MsiDoAction( hpkg, "CostInitialize");
6444     ok( r == ERROR_SUCCESS, "cost init failed\n");
6445
6446     state = 0xdeadbee;
6447     action = 0xdeadbee;
6448     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6449     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6450     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6451     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6452
6453     state = 0xdeadbee;
6454     action = 0xdeadbee;
6455     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6457     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6458     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6459
6460     state = 0xdeadbee;
6461     action = 0xdeadbee;
6462     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6464     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6465     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6466
6467     state = 0xdeadbee;
6468     action = 0xdeadbee;
6469     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6471     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6472     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6473
6474     state = 0xdeadbee;
6475     action = 0xdeadbee;
6476     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6478     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6479     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6480
6481     state = 0xdeadbee;
6482     action = 0xdeadbee;
6483     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6485     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6486     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6487
6488     state = 0xdeadbee;
6489     action = 0xdeadbee;
6490     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6492     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6493     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6494
6495     state = 0xdeadbee;
6496     action = 0xdeadbee;
6497     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6499     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6500     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6501
6502     state = 0xdeadbee;
6503     action = 0xdeadbee;
6504     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6505     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6506     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6507     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6508
6509     state = 0xdeadbee;
6510     action = 0xdeadbee;
6511     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6513     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6514     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6515
6516     state = 0xdeadbee;
6517     action = 0xdeadbee;
6518     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6520     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6521     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6522
6523     state = 0xdeadbee;
6524     action = 0xdeadbee;
6525     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6527     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6528     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6529
6530     state = 0xdeadbee;
6531     action = 0xdeadbee;
6532     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6534     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6535     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6536
6537     state = 0xdeadbee;
6538     action = 0xdeadbee;
6539     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6541     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6542     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6543
6544     state = 0xdeadbee;
6545     action = 0xdeadbee;
6546     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6548     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6549     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6550
6551     state = 0xdeadbee;
6552     action = 0xdeadbee;
6553     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6555     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6556     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6557
6558     state = 0xdeadbee;
6559     action = 0xdeadbee;
6560     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6562     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6563     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6564
6565     state = 0xdeadbee;
6566     action = 0xdeadbee;
6567     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6569     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6570     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6571
6572     state = 0xdeadbee;
6573     action = 0xdeadbee;
6574     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6576     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6577     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6578
6579     state = 0xdeadbee;
6580     action = 0xdeadbee;
6581     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6583     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6584     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6585
6586     state = 0xdeadbee;
6587     action = 0xdeadbee;
6588     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6590     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6591     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6592
6593     state = 0xdeadbee;
6594     action = 0xdeadbee;
6595     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6597     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6598     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6599
6600     state = 0xdeadbee;
6601     action = 0xdeadbee;
6602     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6604     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6605     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6606
6607     state = 0xdeadbee;
6608     action = 0xdeadbee;
6609     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6611     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6612     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6613
6614     state = 0xdeadbee;
6615     action = 0xdeadbee;
6616     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6618     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6619     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6620
6621     state = 0xdeadbee;
6622     action = 0xdeadbee;
6623     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6625     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6626     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6627
6628     state = 0xdeadbee;
6629     action = 0xdeadbee;
6630     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6632     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6633     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6634
6635     state = 0xdeadbee;
6636     action = 0xdeadbee;
6637     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6639     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6640     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6641
6642     state = 0xdeadbee;
6643     action = 0xdeadbee;
6644     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6645     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6646     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6647     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6648
6649     state = 0xdeadbee;
6650     action = 0xdeadbee;
6651     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6653     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6654     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6655
6656     state = 0xdeadbee;
6657     action = 0xdeadbee;
6658     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6660     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6661     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6662
6663     r = MsiDoAction( hpkg, "FileCost");
6664     ok( r == ERROR_SUCCESS, "file cost failed\n");
6665
6666     state = 0xdeadbee;
6667     action = 0xdeadbee;
6668     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6669     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6670     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6671     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6672
6673     state = 0xdeadbee;
6674     action = 0xdeadbee;
6675     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6676     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6677     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6678     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6679
6680     state = 0xdeadbee;
6681     action = 0xdeadbee;
6682     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6683     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6684     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6685     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6686
6687     state = 0xdeadbee;
6688     action = 0xdeadbee;
6689     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6690     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6691     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6692     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6693
6694     state = 0xdeadbee;
6695     action = 0xdeadbee;
6696     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6697     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6698     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6699     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6700
6701     state = 0xdeadbee;
6702     action = 0xdeadbee;
6703     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6705     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6706     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6707
6708     state = 0xdeadbee;
6709     action = 0xdeadbee;
6710     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6712     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6713     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6714
6715     state = 0xdeadbee;
6716     action = 0xdeadbee;
6717     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6718     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6719     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6720     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6721
6722     state = 0xdeadbee;
6723     action = 0xdeadbee;
6724     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6725     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6726     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6727     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6728
6729     state = 0xdeadbee;
6730     action = 0xdeadbee;
6731     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6732     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6733     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6734     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6735
6736     state = 0xdeadbee;
6737     action = 0xdeadbee;
6738     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6739     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6740     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6741     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6742
6743     state = 0xdeadbee;
6744     action = 0xdeadbee;
6745     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6746     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6747     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6748     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6749
6750     state = 0xdeadbee;
6751     action = 0xdeadbee;
6752     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6753     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6754     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6755     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6756
6757     state = 0xdeadbee;
6758     action = 0xdeadbee;
6759     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6760     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6761     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6762     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6763
6764     state = 0xdeadbee;
6765     action = 0xdeadbee;
6766     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6767     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6768     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6769     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6770
6771     state = 0xdeadbee;
6772     action = 0xdeadbee;
6773     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6774     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6775     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6776     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6777
6778     state = 0xdeadbee;
6779     action = 0xdeadbee;
6780     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6781     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6782     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6783     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6784
6785     state = 0xdeadbee;
6786     action = 0xdeadbee;
6787     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6788     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6789     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6790     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6791
6792     state = 0xdeadbee;
6793     action = 0xdeadbee;
6794     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6795     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6796     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6797     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6798
6799     state = 0xdeadbee;
6800     action = 0xdeadbee;
6801     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6802     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6803     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6804     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6805
6806     state = 0xdeadbee;
6807     action = 0xdeadbee;
6808     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6809     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6810     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6811     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6812
6813     state = 0xdeadbee;
6814     action = 0xdeadbee;
6815     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6816     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6817     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6818     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6819
6820     state = 0xdeadbee;
6821     action = 0xdeadbee;
6822     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6823     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6824     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6825     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6826
6827     state = 0xdeadbee;
6828     action = 0xdeadbee;
6829     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6830     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6831     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6832     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6833
6834     state = 0xdeadbee;
6835     action = 0xdeadbee;
6836     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6837     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6838     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6839     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6840
6841     state = 0xdeadbee;
6842     action = 0xdeadbee;
6843     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6844     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6845     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6846     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6847
6848     state = 0xdeadbee;
6849     action = 0xdeadbee;
6850     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6851     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6852     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6853     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6854
6855     state = 0xdeadbee;
6856     action = 0xdeadbee;
6857     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6858     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6859     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6860     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6861
6862     state = 0xdeadbee;
6863     action = 0xdeadbee;
6864     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6865     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6866     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6867     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6868
6869     state = 0xdeadbee;
6870     action = 0xdeadbee;
6871     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6872     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6873     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6874     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6875
6876     state = 0xdeadbee;
6877     action = 0xdeadbee;
6878     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6879     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6880     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6881     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6882
6883     r = MsiDoAction( hpkg, "CostFinalize");
6884     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6885
6886     state = 0xdeadbee;
6887     action = 0xdeadbee;
6888     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6889     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6890     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6891     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6892
6893     state = 0xdeadbee;
6894     action = 0xdeadbee;
6895     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6896     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6897     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6898     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6899
6900     state = 0xdeadbee;
6901     action = 0xdeadbee;
6902     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6903     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6904     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6905     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6906
6907     state = 0xdeadbee;
6908     action = 0xdeadbee;
6909     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6910     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6911     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6912     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6913
6914     state = 0xdeadbee;
6915     action = 0xdeadbee;
6916     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6917     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6918     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6919     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6920
6921     state = 0xdeadbee;
6922     action = 0xdeadbee;
6923     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6924     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6925     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6926     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6927
6928     state = 0xdeadbee;
6929     action = 0xdeadbee;
6930     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6931     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6932     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6933     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6934
6935     state = 0xdeadbee;
6936     action = 0xdeadbee;
6937     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6938     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6939     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6940     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6941
6942     state = 0xdeadbee;
6943     action = 0xdeadbee;
6944     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6945     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6946     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6947     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6948
6949     state = 0xdeadbee;
6950     action = 0xdeadbee;
6951     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6952     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6953     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6954     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6955
6956     state = 0xdeadbee;
6957     action = 0xdeadbee;
6958     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6959     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6960     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6961     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6962
6963     state = 0xdeadbee;
6964     action = 0xdeadbee;
6965     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6966     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6967     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6968     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6969
6970     state = 0xdeadbee;
6971     action = 0xdeadbee;
6972     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6973     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6974     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6975     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6976
6977     state = 0xdeadbee;
6978     action = 0xdeadbee;
6979     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6980     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6981     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6982     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6983
6984     state = 0xdeadbee;
6985     action = 0xdeadbee;
6986     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6987     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6988     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6989     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6990
6991     state = 0xdeadbee;
6992     action = 0xdeadbee;
6993     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6994     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6995     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6996     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6997
6998     state = 0xdeadbee;
6999     action = 0xdeadbee;
7000     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7001     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7002     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7003     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7004
7005     state = 0xdeadbee;
7006     action = 0xdeadbee;
7007     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7008     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7009     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7010     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7011
7012     state = 0xdeadbee;
7013     action = 0xdeadbee;
7014     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7015     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7016     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7017     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7018
7019     state = 0xdeadbee;
7020     action = 0xdeadbee;
7021     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7022     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7023     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7024     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7025
7026     state = 0xdeadbee;
7027     action = 0xdeadbee;
7028     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7029     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7030     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7031     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7032
7033     state = 0xdeadbee;
7034     action = 0xdeadbee;
7035     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7036     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7037     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7038     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7039
7040     state = 0xdeadbee;
7041     action = 0xdeadbee;
7042     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7043     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7044     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7045     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7046
7047     state = 0xdeadbee;
7048     action = 0xdeadbee;
7049     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7050     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7051     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7052     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7053
7054     state = 0xdeadbee;
7055     action = 0xdeadbee;
7056     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7057     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7058     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7059     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7060
7061     state = 0xdeadbee;
7062     action = 0xdeadbee;
7063     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7064     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7065     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7066     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7067
7068     state = 0xdeadbee;
7069     action = 0xdeadbee;
7070     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7071     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7072     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7073     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7074
7075     state = 0xdeadbee;
7076     action = 0xdeadbee;
7077     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7079     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7080     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7081
7082     state = 0xdeadbee;
7083     action = 0xdeadbee;
7084     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7086     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7087     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7088
7089     state = 0xdeadbee;
7090     action = 0xdeadbee;
7091     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7093     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7094     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7095
7096     state = 0xdeadbee;
7097     action = 0xdeadbee;
7098     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7100     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7101     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7102
7103     MsiCloseHandle(hpkg);
7104
7105     /* uninstall the product */
7106     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7108
7109     DeleteFileA(msifile);
7110     DeleteFileA(msifile2);
7111     DeleteFileA(msifile3);
7112     DeleteFileA(msifile4);
7113 }
7114
7115 static void test_getproperty(void)
7116 {
7117     MSIHANDLE hPackage = 0;
7118     char prop[100];
7119     static CHAR empty[] = "";
7120     DWORD size;
7121     UINT r;
7122
7123     hPackage = package_from_db(create_package_db());
7124     ok( hPackage != 0, " Failed to create package\n");
7125
7126     /* set the property */
7127     r = MsiSetProperty(hPackage, "Name", "Value");
7128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7129
7130     /* retrieve the size, NULL pointer */
7131     size = 0;
7132     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7134     ok( size == 5, "Expected 5, got %d\n", size);
7135
7136     /* retrieve the size, empty string */
7137     size = 0;
7138     r = MsiGetProperty(hPackage, "Name", empty, &size);
7139     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7140     ok( size == 5, "Expected 5, got %d\n", size);
7141
7142     /* don't change size */
7143     r = MsiGetProperty(hPackage, "Name", prop, &size);
7144     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7145     ok( size == 5, "Expected 5, got %d\n", size);
7146     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7147
7148     /* increase the size by 1 */
7149     size++;
7150     r = MsiGetProperty(hPackage, "Name", prop, &size);
7151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7152     ok( size == 5, "Expected 5, got %d\n", size);
7153     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7154
7155     r = MsiCloseHandle( hPackage);
7156     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7157     DeleteFile(msifile);
7158 }
7159
7160 static void test_removefiles(void)
7161 {
7162     MSIHANDLE hpkg;
7163     UINT r;
7164     MSIHANDLE hdb;
7165
7166     hdb = create_package_db();
7167     ok ( hdb, "failed to create package database\n" );
7168
7169     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7170     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7171
7172     r = create_feature_table( hdb );
7173     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7174
7175     r = create_component_table( hdb );
7176     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7177
7178     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7179     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7180
7181     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7182     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7183
7184     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7185     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7186
7187     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7188     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7189
7190     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7191     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7192
7193     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7194     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7195
7196     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7197     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7198
7199     r = create_feature_components_table( hdb );
7200     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7201
7202     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7203     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7204
7205     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7206     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7207
7208     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7209     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7210
7211     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7212     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7213
7214     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7215     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7216
7217     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7218     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7219
7220     r = create_file_table( hdb );
7221     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7222
7223     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7224     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7225
7226     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7227     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7228
7229     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7230     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7231
7232     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7233     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7234
7235     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7236     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7237
7238     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7239     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7240
7241     r = create_remove_file_table( hdb );
7242     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7243
7244     hpkg = package_from_db( hdb );
7245     ok( hpkg, "failed to create package\n");
7246
7247     MsiCloseHandle( hdb );
7248
7249     create_test_file( "hydrogen.txt" );
7250     create_test_file( "helium.txt" );
7251     create_test_file( "lithium.txt" );
7252     create_test_file( "beryllium.txt" );
7253     create_test_file( "boron.txt" );
7254     create_test_file( "carbon.txt" );
7255
7256     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7257     ok( r == ERROR_SUCCESS, "set property failed\n");
7258
7259     r = MsiDoAction( hpkg, "CostInitialize");
7260     ok( r == ERROR_SUCCESS, "cost init failed\n");
7261
7262     r = MsiDoAction( hpkg, "FileCost");
7263     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7264
7265     r = MsiDoAction( hpkg, "CostFinalize");
7266     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7267
7268     r = MsiDoAction( hpkg, "InstallValidate");
7269     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7270
7271     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7272     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7273
7274     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7275     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7276
7277     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7278     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7279
7280     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7281     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7282
7283     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7284     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7285
7286     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7287     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7288
7289     r = MsiDoAction( hpkg, "RemoveFiles");
7290     ok( r == ERROR_SUCCESS, "remove files failed\n");
7291
7292     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7293     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7294     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7295     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7296     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7297     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7298
7299     MsiCloseHandle( hpkg );
7300     DeleteFileA(msifile);
7301 }
7302
7303 static void test_appsearch(void)
7304 {
7305     MSIHANDLE hpkg;
7306     UINT r;
7307     MSIHANDLE hdb;
7308     CHAR prop[MAX_PATH];
7309     DWORD size = MAX_PATH;
7310
7311     hdb = create_package_db();
7312     ok ( hdb, "failed to create package database\n" );
7313
7314     r = create_appsearch_table( hdb );
7315     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7316
7317     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7318     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7319
7320     r = create_reglocator_table( hdb );
7321     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7322
7323     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
7324     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7325
7326     r = create_signature_table( hdb );
7327     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7328
7329     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7330     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7331
7332     hpkg = package_from_db( hdb );
7333     ok( hpkg, "failed to create package\n");
7334
7335     MsiCloseHandle( hdb );
7336
7337     r = MsiDoAction( hpkg, "AppSearch" );
7338     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7339
7340     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7341     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7342     todo_wine
7343     {
7344         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7345     }
7346
7347     MsiCloseHandle( hpkg );
7348     DeleteFileA(msifile);
7349 }
7350
7351 static void test_appsearch_complocator(void)
7352 {
7353     MSIHANDLE hpkg, hdb;
7354     CHAR path[MAX_PATH];
7355     CHAR prop[MAX_PATH];
7356     LPSTR usersid;
7357     DWORD size;
7358     UINT r;
7359
7360     if (!get_user_sid(&usersid))
7361         return;
7362
7363     create_test_file("FileName1");
7364     create_test_file("FileName4");
7365     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
7366                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
7367
7368     create_test_file("FileName2");
7369     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
7370                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
7371
7372     create_test_file("FileName3");
7373     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
7374                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
7375
7376     create_test_file("FileName5");
7377     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
7378                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
7379
7380     create_test_file("FileName6");
7381     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
7382                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
7383
7384     create_test_file("FileName7");
7385     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
7386                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
7387
7388     /* dir is FALSE, but we're pretending it's a directory */
7389     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
7390                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
7391
7392     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7393     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
7394                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
7395
7396     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7397     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
7398                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
7399
7400     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7401     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
7402                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
7403
7404     hdb = create_package_db();
7405     ok(hdb, "Expected a valid database handle\n");
7406
7407     r = create_appsearch_table(hdb);
7408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7409
7410     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7411     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7412
7413     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
7414     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7415
7416     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
7417     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7418
7419     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
7420     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7421
7422     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
7423     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7424
7425     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
7426     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7427
7428     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
7429     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7430
7431     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
7432     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7433
7434     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
7435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7436
7437     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
7438     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7439
7440     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
7441     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7442
7443     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
7444     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7445
7446     r = create_complocator_table(hdb);
7447     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7448
7449     /* published component, machine, file, signature, misdbLocatorTypeFile */
7450     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
7451     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7452
7453     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
7454     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
7455     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7456
7457     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
7458     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
7459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7460
7461     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
7462     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
7463     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7464
7465     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
7466     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
7467     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7468
7469     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
7470     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
7471     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7472
7473     /* published component, machine, file, no signature, misdbLocatorTypeFile */
7474     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
7475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7476
7477     /* unpublished component, no signature, misdbLocatorTypeDir */
7478     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
7479     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7480
7481     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
7482     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
7483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7484
7485     /* published component, signature w/ ver, misdbLocatorTypeFile */
7486     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
7487     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7488
7489     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
7490     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
7491     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7492
7493     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
7494     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
7495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7496
7497     r = create_signature_table(hdb);
7498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7499
7500     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
7501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7502
7503     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
7504     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7505
7506     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
7507     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7508
7509     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
7510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7511
7512     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
7513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7514
7515     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7517
7518     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7519     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7520
7521     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7523
7524     hpkg = package_from_db(hdb);
7525     ok(hpkg, "Expected a valid package handle\n");
7526
7527     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
7528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7529
7530     r = MsiDoAction(hpkg, "AppSearch");
7531     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7532
7533     size = MAX_PATH;
7534     sprintf(path, "%s\\FileName1", CURR_DIR);
7535     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
7536     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7537     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7538
7539     size = MAX_PATH;
7540     sprintf(path, "%s\\FileName2", CURR_DIR);
7541     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
7542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7543     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7544
7545     size = MAX_PATH;
7546     sprintf(path, "%s\\FileName3", CURR_DIR);
7547     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
7548     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7549     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7550
7551     size = MAX_PATH;
7552     sprintf(path, "%s\\FileName4", CURR_DIR);
7553     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
7554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7555     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7556
7557     size = MAX_PATH;
7558     sprintf(path, "%s\\FileName5", CURR_DIR);
7559     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
7560     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7561     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7562
7563     size = MAX_PATH;
7564     sprintf(path, "%s\\", CURR_DIR);
7565     r = MsiGetPropertyA(hpkg, "SIGPROP6", 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\\", CURR_DIR);
7571     r = MsiGetPropertyA(hpkg, "SIGPROP7", 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     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
7577     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7578     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
7579
7580     size = MAX_PATH;
7581     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
7582     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7583     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7584
7585     size = MAX_PATH;
7586     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
7587     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
7588     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7589     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7590
7591     size = MAX_PATH;
7592     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
7593     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7594     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7595
7596     size = MAX_PATH;
7597     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
7598     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
7599     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7600     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7601
7602     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
7603                           MSIINSTALLCONTEXT_MACHINE, NULL);
7604     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
7605                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
7606     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
7607                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
7608     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
7609                           MSIINSTALLCONTEXT_MACHINE, NULL);
7610     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
7611                           MSIINSTALLCONTEXT_MACHINE, NULL);
7612     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
7613                           MSIINSTALLCONTEXT_MACHINE, NULL);
7614     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
7615                           MSIINSTALLCONTEXT_MACHINE, NULL);
7616     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
7617                           MSIINSTALLCONTEXT_MACHINE, NULL);
7618     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
7619                           MSIINSTALLCONTEXT_MACHINE, NULL);
7620     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
7621                           MSIINSTALLCONTEXT_MACHINE, NULL);
7622
7623     DeleteFileA("FileName1");
7624     DeleteFileA("FileName2");
7625     DeleteFileA("FileName3");
7626     DeleteFileA("FileName4");
7627     DeleteFileA("FileName5");
7628     DeleteFileA("FileName6");
7629     DeleteFileA("FileName7");
7630     DeleteFileA("FileName8.dll");
7631     DeleteFileA("FileName9.dll");
7632     DeleteFileA("FileName10.dll");
7633     MsiCloseHandle(hpkg);
7634     DeleteFileA(msifile);
7635 }
7636
7637 static void test_appsearch_reglocator(void)
7638 {
7639     MSIHANDLE hpkg, hdb;
7640     CHAR path[MAX_PATH];
7641     CHAR prop[MAX_PATH];
7642     DWORD binary[2];
7643     DWORD size, val;
7644     BOOL space, version;
7645     HKEY hklm, classes;
7646     HKEY hkcu, users;
7647     LPSTR pathdata;
7648     LPSTR pathvar;
7649     LPCSTR str;
7650     LPSTR ptr;
7651     LONG res;
7652     UINT r;
7653
7654     version = TRUE;
7655     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
7656         version = FALSE;
7657
7658     DeleteFileA("test.dll");
7659
7660     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
7661     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7662
7663     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
7664                          (const BYTE *)"regszdata", 10);
7665     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7666
7667     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
7668     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7669
7670     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
7671                          (const BYTE *)"regszdata", 10);
7672     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7673
7674     users = 0;
7675     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
7676     ok(res == ERROR_SUCCESS ||
7677        broken(res == ERROR_INVALID_PARAMETER),
7678        "Expected ERROR_SUCCESS, got %d\n", res);
7679
7680     if (res == ERROR_SUCCESS)
7681     {
7682         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
7683                              (const BYTE *)"regszdata", 10);
7684         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7685     }
7686
7687     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
7688     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7689
7690     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
7691     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7692
7693     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
7694                          (const BYTE *)"regszdata", 10);
7695     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7696
7697     val = 42;
7698     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
7699                          (const BYTE *)&val, sizeof(DWORD));
7700     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7701
7702     val = -42;
7703     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
7704                          (const BYTE *)&val, sizeof(DWORD));
7705     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7706
7707     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
7708                          (const BYTE *)"%PATH%", 7);
7709     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7710
7711     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
7712                          (const BYTE *)"my%NOVAR%", 10);
7713     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7714
7715     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
7716                          (const BYTE *)"one\0two\0", 9);
7717     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7718
7719     binary[0] = 0x1234abcd;
7720     binary[1] = 0x567890ef;
7721     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
7722                          (const BYTE *)binary, sizeof(binary));
7723     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7724
7725     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
7726                          (const BYTE *)"#regszdata", 11);
7727     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7728
7729     create_test_file("FileName1");
7730     sprintf(path, "%s\\FileName1", CURR_DIR);
7731     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
7732                          (const BYTE *)path, lstrlenA(path) + 1);
7733     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7734
7735     sprintf(path, "%s\\FileName2", CURR_DIR);
7736     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
7737                          (const BYTE *)path, lstrlenA(path) + 1);
7738     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7739
7740     lstrcpyA(path, CURR_DIR);
7741     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
7742                          (const BYTE *)path, lstrlenA(path) + 1);
7743     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7744
7745     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
7746                          (const BYTE *)"", 1);
7747     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7748
7749     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7750     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
7751     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
7752                          (const BYTE *)path, lstrlenA(path) + 1);
7753     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7754
7755     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7756     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
7757     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
7758                          (const BYTE *)path, lstrlenA(path) + 1);
7759     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7760
7761     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7762     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
7763     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
7764                          (const BYTE *)path, lstrlenA(path) + 1);
7765     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7766
7767     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
7768     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
7769                          (const BYTE *)path, lstrlenA(path) + 1);
7770
7771     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
7772     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
7773     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
7774                          (const BYTE *)path, lstrlenA(path) + 1);
7775
7776     hdb = create_package_db();
7777     ok(hdb, "Expected a valid database handle\n");
7778
7779     r = create_appsearch_table(hdb);
7780     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7781
7782     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7783     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7784
7785     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
7786     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7787
7788     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
7789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7790
7791     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
7792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7793
7794     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
7795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7796
7797     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
7798     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7799
7800     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
7801     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7802
7803     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
7804     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7805
7806     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
7807     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7808
7809     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
7810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7811
7812     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
7813     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7814
7815     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
7816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7817
7818     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
7819     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7820
7821     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
7822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7823
7824     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
7825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7826
7827     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
7828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7829
7830     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
7831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7832
7833     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
7834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7835
7836     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
7837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7838
7839     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
7840     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7841
7842     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
7843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7844
7845     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
7846     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7847
7848     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
7849     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7850
7851     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
7852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7853
7854     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
7855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7856
7857     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
7858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7859
7860     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
7861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7862
7863     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
7864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7865
7866     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
7867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7868
7869     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
7870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7871
7872     r = create_reglocator_table(hdb);
7873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7874
7875     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
7876     str = "'NewSignature1', 2, 'Software\\Wine', 'Value1', 2";
7877     r = add_reglocator_entry(hdb, str);
7878     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7879
7880     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
7881     str = "'NewSignature2', 2, 'Software\\Wine', 'Value2', 2";
7882     r = add_reglocator_entry(hdb, str);
7883     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7884
7885     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
7886     str = "'NewSignature3', 2, 'Software\\Wine', 'Value3', 2";
7887     r = add_reglocator_entry(hdb, str);
7888     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7889
7890     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
7891     str = "'NewSignature4', 2, 'Software\\Wine', 'Value4', 2";
7892     r = add_reglocator_entry(hdb, str);
7893     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7894
7895     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
7896     str = "'NewSignature5', 2, 'Software\\Wine', 'Value5', 2";
7897     r = add_reglocator_entry(hdb, str);
7898     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7899
7900     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
7901     str = "'NewSignature6', 2, 'Software\\Wine', 'Value6', 2";
7902     r = add_reglocator_entry(hdb, str);
7903     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7904
7905     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
7906     str = "'NewSignature7', 2, 'Software\\Wine', 'Value7', 2";
7907     r = add_reglocator_entry(hdb, str);
7908     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7909
7910     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
7911     str = "'NewSignature8', 2, 'Software\\Wine', 'Value8', 2";
7912     r = add_reglocator_entry(hdb, str);
7913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7914
7915     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
7916     str = "'NewSignature9', 2, 'Software\\Wine', 'Value9', 1";
7917     r = add_reglocator_entry(hdb, str);
7918     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7919
7920     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
7921     str = "'NewSignature10', 2, 'Software\\Wine', 'Value10', 1";
7922     r = add_reglocator_entry(hdb, str);
7923     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7924
7925     /* HKLM, msidbLocatorTypeFileName, no signature */
7926     str = "'NewSignature11', 2, 'Software\\Wine', 'Value9', 1";
7927     r = add_reglocator_entry(hdb, str);
7928     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7929
7930     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
7931     str = "'NewSignature12', 2, 'Software\\Wine', 'Value9', 0";
7932     r = add_reglocator_entry(hdb, str);
7933     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7934
7935     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
7936     str = "'NewSignature13', 2, 'Software\\Wine', 'Value11', 0";
7937     r = add_reglocator_entry(hdb, str);
7938     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7939
7940     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
7941     str = "'NewSignature14', 2, 'Software\\Wine', 'Value9', 0";
7942     r = add_reglocator_entry(hdb, str);
7943     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7944
7945     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
7946     str = "'NewSignature15', 0, 'Software\\Wine', 'Value1', 2";
7947     r = add_reglocator_entry(hdb, str);
7948     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7949
7950     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
7951     str = "'NewSignature16', 1, 'Software\\Wine', 'Value1', 2";
7952     r = add_reglocator_entry(hdb, str);
7953     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7954
7955     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
7956     str = "'NewSignature17', 3, 'S-1-5-18\\Software\\Wine', 'Value1', 2";
7957     r = add_reglocator_entry(hdb, str);
7958     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7959
7960     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
7961     str = "'NewSignature18', 2, 'Software\\Wine', '', 2";
7962     r = add_reglocator_entry(hdb, str);
7963     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7964
7965     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
7966     str = "'NewSignature19', 2, 'Software\\IDontExist', '', 2";
7967     r = add_reglocator_entry(hdb, str);
7968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7969
7970     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
7971     str = "'NewSignature20', 2, 'Software\\Wine', 'Value12', 2";
7972     r = add_reglocator_entry(hdb, str);
7973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7974
7975     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
7976     str = "'NewSignature21', 2, 'Software\\Wine', 'Value13', 1";
7977     r = add_reglocator_entry(hdb, str);
7978     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7979
7980     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
7981     str = "'NewSignature22', 2, 'Software\\Wine', 'Value14', 1";
7982     r = add_reglocator_entry(hdb, str);
7983     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7984
7985     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
7986     str = "'NewSignature23', 2, 'Software\\Wine', 'Value15', 1";
7987     r = add_reglocator_entry(hdb, str);
7988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7989
7990     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
7991     str = "'NewSignature24', 2, 'Software\\Wine', 'Value11', 1";
7992     r = add_reglocator_entry(hdb, str);
7993     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7994
7995     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
7996     str = "'NewSignature25', 2, 'Software\\Wine', 'Value10', 1";
7997     r = add_reglocator_entry(hdb, str);
7998     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7999
8000     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8001     str = "'NewSignature26', 2, 'Software\\Wine', 'Value11', 0";
8002     r = add_reglocator_entry(hdb, str);
8003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8004
8005     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8006     str = "'NewSignature27', 2, 'Software\\Wine', 'Value10', 0";
8007     r = add_reglocator_entry(hdb, str);
8008     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8009
8010     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8011     str = "'NewSignature28', 2, 'Software\\Wine', 'Value10', 0";
8012     r = add_reglocator_entry(hdb, str);
8013     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8014
8015     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8016     str = "'NewSignature29', 2, 'Software\\Wine', 'Value16', 1";
8017     r = add_reglocator_entry(hdb, str);
8018     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8019
8020     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8021     str = "'NewSignature30', 2, 'Software\\Wine', 'Value17', 1";
8022     r = add_reglocator_entry(hdb, str);
8023     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8024
8025     r = create_signature_table(hdb);
8026     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8027
8028     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8029     r = add_signature_entry(hdb, str);
8030     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8031
8032     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8033     r = add_signature_entry(hdb, str);
8034     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8035
8036     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8037     r = add_signature_entry(hdb, str);
8038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8039
8040     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8041     r = add_signature_entry(hdb, str);
8042     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8043
8044     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8045     r = add_signature_entry(hdb, str);
8046     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8047
8048     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8049     r = add_signature_entry(hdb, str);
8050     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8051
8052     ptr = strrchr(CURR_DIR, '\\') + 1;
8053     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8054     r = add_signature_entry(hdb, path);
8055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8056
8057     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8058     r = add_signature_entry(hdb, str);
8059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8060
8061     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8062     r = add_signature_entry(hdb, str);
8063     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8064
8065     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8066     r = add_signature_entry(hdb, str);
8067     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8068
8069     hpkg = package_from_db(hdb);
8070     ok(hpkg, "Expected a valid package handle\n");
8071
8072     r = MsiDoAction(hpkg, "AppSearch");
8073     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8074
8075     size = MAX_PATH;
8076     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8078     ok(!lstrcmpA(prop, "regszdata"),
8079        "Expected \"regszdata\", got \"%s\"\n", prop);
8080
8081     size = MAX_PATH;
8082     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8084     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8085
8086     size = MAX_PATH;
8087     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8088     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8089     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8090
8091     size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8092     if (size == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
8093     {
8094         /* Workaround for Win95 */
8095         CHAR tempbuf[1];
8096         size = ExpandEnvironmentStringsA("%PATH%", tempbuf, 0);
8097     }
8098     pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8099     ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8100
8101     size = 0;
8102     r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8103     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8104
8105     pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8106     r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8108     ok(!lstrcmpA(pathdata, pathvar),
8109        "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8110
8111     HeapFree(GetProcessHeap(), 0, pathvar);
8112     HeapFree(GetProcessHeap(), 0, pathdata);
8113
8114     size = MAX_PATH;
8115     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8116     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8117     ok(!lstrcmpA(prop,
8118        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8119
8120     size = MAX_PATH;
8121     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8123     todo_wine
8124     {
8125         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8126            "Expected \"\\0one\\0two\\0\\0\"\n");
8127     }
8128
8129     size = MAX_PATH;
8130     lstrcpyA(path, "#xCDAB3412EF907856");
8131     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8132     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8133     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8134
8135     size = MAX_PATH;
8136     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8138     ok(!lstrcmpA(prop, "##regszdata"),
8139        "Expected \"##regszdata\", got \"%s\"\n", prop);
8140
8141     size = MAX_PATH;
8142     sprintf(path, "%s\\FileName1", CURR_DIR);
8143     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8144     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8145     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8146
8147     size = MAX_PATH;
8148     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8149     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8150     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8151
8152     size = MAX_PATH;
8153     sprintf(path, "%s\\", CURR_DIR);
8154     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8155     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8156     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8157
8158     size = MAX_PATH;
8159     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8160     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8161     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8162
8163     size = MAX_PATH;
8164     sprintf(path, "%s\\", CURR_DIR);
8165     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
8166     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8167     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8168
8169     size = MAX_PATH;
8170     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
8171     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8173
8174     size = MAX_PATH;
8175     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8176     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8177     ok(!lstrcmpA(prop, "regszdata"),
8178        "Expected \"regszdata\", got \"%s\"\n", prop);
8179
8180     size = MAX_PATH;
8181     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8182     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8183     ok(!lstrcmpA(prop, "regszdata"),
8184        "Expected \"regszdata\", got \"%s\"\n", prop);
8185
8186     if (users)
8187     {
8188         size = MAX_PATH;
8189         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8190         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8191         ok(!lstrcmpA(prop, "regszdata"),
8192            "Expected \"regszdata\", got \"%s\"\n", prop);
8193     }
8194
8195     size = MAX_PATH;
8196     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8197     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8198     ok(!lstrcmpA(prop, "defvalue"),
8199        "Expected \"defvalue\", got \"%s\"\n", prop);
8200
8201     size = MAX_PATH;
8202     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8203     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8204     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8205
8206     size = MAX_PATH;
8207     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
8208     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8209     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8210
8211     if (version)
8212     {
8213         size = MAX_PATH;
8214         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8215         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8216         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8217         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8218
8219         size = MAX_PATH;
8220         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8221         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8222         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8223
8224         size = MAX_PATH;
8225         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8226         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8227         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8228         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8229     }
8230
8231     size = MAX_PATH;
8232     lstrcpyA(path, CURR_DIR);
8233     ptr = strrchr(path, '\\') + 1;
8234     *ptr = '\0';
8235     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8236     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8237     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8238
8239     size = MAX_PATH;
8240     sprintf(path, "%s\\", CURR_DIR);
8241     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8242     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8243     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8244
8245     size = MAX_PATH;
8246     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8247     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8248     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8249
8250     size = MAX_PATH;
8251     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8252     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8253     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8254
8255     size = MAX_PATH;
8256     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8257     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8258     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8259
8260     size = MAX_PATH;
8261     sprintf(path, "%s\\FileName1", CURR_DIR);
8262     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8263     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8264     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8265
8266     size = MAX_PATH;
8267     sprintf(path, "%s\\FileName1", CURR_DIR);
8268     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8269     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8270     if (space)
8271         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8272     else
8273         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8274
8275     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8276     RegDeleteValueA(hklm, "Value1");
8277     RegDeleteValueA(hklm, "Value2");
8278     RegDeleteValueA(hklm, "Value3");
8279     RegDeleteValueA(hklm, "Value4");
8280     RegDeleteValueA(hklm, "Value5");
8281     RegDeleteValueA(hklm, "Value6");
8282     RegDeleteValueA(hklm, "Value7");
8283     RegDeleteValueA(hklm, "Value8");
8284     RegDeleteValueA(hklm, "Value9");
8285     RegDeleteValueA(hklm, "Value10");
8286     RegDeleteValueA(hklm, "Value11");
8287     RegDeleteValueA(hklm, "Value12");
8288     RegDeleteValueA(hklm, "Value13");
8289     RegDeleteValueA(hklm, "Value14");
8290     RegDeleteValueA(hklm, "Value15");
8291     RegDeleteValueA(hklm, "Value16");
8292     RegDeleteValueA(hklm, "Value17");
8293     RegDeleteKeyA(hklm, "");
8294     RegCloseKey(hklm);
8295
8296     RegDeleteValueA(classes, "Value1");
8297     RegDeleteKeyA(classes, "");
8298     RegCloseKey(classes);
8299
8300     RegDeleteValueA(hkcu, "Value1");
8301     RegDeleteKeyA(hkcu, "");
8302     RegCloseKey(hkcu);
8303
8304     RegDeleteValueA(users, "Value1");
8305     RegDeleteKeyA(users, "");
8306     RegCloseKey(users);
8307
8308     DeleteFileA("FileName1");
8309     DeleteFileA("FileName3.dll");
8310     DeleteFileA("FileName4.dll");
8311     DeleteFileA("FileName5.dll");
8312     MsiCloseHandle(hpkg);
8313     DeleteFileA(msifile);
8314 }
8315
8316 static void delete_win_ini(LPCSTR file)
8317 {
8318     CHAR path[MAX_PATH];
8319
8320     GetWindowsDirectoryA(path, MAX_PATH);
8321     lstrcatA(path, "\\");
8322     lstrcatA(path, file);
8323
8324     DeleteFileA(path);
8325 }
8326
8327 static void test_appsearch_inilocator(void)
8328 {
8329     MSIHANDLE hpkg, hdb;
8330     CHAR path[MAX_PATH];
8331     CHAR prop[MAX_PATH];
8332     BOOL version;
8333     LPCSTR str;
8334     LPSTR ptr;
8335     DWORD size;
8336     UINT r;
8337
8338     version = TRUE;
8339     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8340         version = FALSE;
8341
8342     DeleteFileA("test.dll");
8343
8344     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
8345
8346     create_test_file("FileName1");
8347     sprintf(path, "%s\\FileName1", CURR_DIR);
8348     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
8349
8350     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
8351
8352     sprintf(path, "%s\\IDontExist", CURR_DIR);
8353     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
8354
8355     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8356     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8357     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
8358
8359     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8360     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8361     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
8362
8363     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8364     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8365     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
8366
8367     hdb = create_package_db();
8368     ok(hdb, "Expected a valid database handle\n");
8369
8370     r = create_appsearch_table(hdb);
8371     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8372
8373     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8374     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8375
8376     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8377     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8378
8379     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8380     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8381
8382     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8383     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8384
8385     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8386     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8387
8388     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8389     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8390
8391     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8392     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8393
8394     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8395     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8396
8397     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8398     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8399
8400     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8401     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8402
8403     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8404     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8405
8406     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8408
8409     r = create_inilocator_table(hdb);
8410     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8411
8412     /* msidbLocatorTypeRawValue, field 1 */
8413     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
8414     r = add_inilocator_entry(hdb, str);
8415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8416
8417     /* msidbLocatorTypeRawValue, field 2 */
8418     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
8419     r = add_inilocator_entry(hdb, str);
8420     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8421
8422     /* msidbLocatorTypeRawValue, entire field */
8423     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
8424     r = add_inilocator_entry(hdb, str);
8425     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8426
8427     /* msidbLocatorTypeFile */
8428     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8429     r = add_inilocator_entry(hdb, str);
8430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8431
8432     /* msidbLocatorTypeDirectory, file */
8433     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
8434     r = add_inilocator_entry(hdb, str);
8435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8436
8437     /* msidbLocatorTypeDirectory, directory */
8438     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
8439     r = add_inilocator_entry(hdb, str);
8440     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8441
8442     /* msidbLocatorTypeFile, file, no signature */
8443     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8444     r = add_inilocator_entry(hdb, str);
8445     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8446
8447     /* msidbLocatorTypeFile, dir, no signature */
8448     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
8449     r = add_inilocator_entry(hdb, str);
8450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8451
8452     /* msidbLocatorTypeFile, file does not exist */
8453     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
8454     r = add_inilocator_entry(hdb, str);
8455     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8456
8457     /* msidbLocatorTypeFile, signature with version */
8458     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
8459     r = add_inilocator_entry(hdb, str);
8460     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8461
8462     /* msidbLocatorTypeFile, signature with version, ver > max */
8463     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
8464     r = add_inilocator_entry(hdb, str);
8465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8466
8467     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
8468     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
8469     r = add_inilocator_entry(hdb, str);
8470     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8471
8472     r = create_signature_table(hdb);
8473     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8474
8475     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
8476     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8477
8478     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
8479     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8480
8481     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8482     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8483
8484     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8486
8487     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8488     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8489
8490     hpkg = package_from_db(hdb);
8491     ok(hpkg, "Expected a valid package handle\n");
8492
8493     r = MsiDoAction(hpkg, "AppSearch");
8494     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8495
8496     size = MAX_PATH;
8497     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8499     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
8500
8501     size = MAX_PATH;
8502     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8503     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8504     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
8505
8506     size = MAX_PATH;
8507     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8508     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8509     ok(!lstrcmpA(prop, "keydata,field2"),
8510        "Expected \"keydata,field2\", got \"%s\"\n", prop);
8511
8512     size = MAX_PATH;
8513     sprintf(path, "%s\\FileName1", CURR_DIR);
8514     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8515     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8516     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8517
8518     size = MAX_PATH;
8519     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8520     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8521     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8522
8523     size = MAX_PATH;
8524     sprintf(path, "%s\\", CURR_DIR);
8525     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8526     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8527     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8528
8529     size = MAX_PATH;
8530     sprintf(path, "%s\\", CURR_DIR);
8531     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8532     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8533     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8534
8535     size = MAX_PATH;
8536     lstrcpyA(path, CURR_DIR);
8537     ptr = strrchr(path, '\\');
8538     *(ptr + 1) = '\0';
8539     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8541     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8542
8543     size = MAX_PATH;
8544     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8545     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8546     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8547
8548     if (version)
8549     {
8550         size = MAX_PATH;
8551         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8552         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8553         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8554         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8555
8556         size = MAX_PATH;
8557         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8558         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8559         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8560
8561         size = MAX_PATH;
8562         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8563         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8564         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8565         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8566     }
8567
8568     delete_win_ini("IniFile.ini");
8569     DeleteFileA("FileName1");
8570     DeleteFileA("FileName2.dll");
8571     DeleteFileA("FileName3.dll");
8572     DeleteFileA("FileName4.dll");
8573     MsiCloseHandle(hpkg);
8574     DeleteFileA(msifile);
8575 }
8576
8577 /*
8578  * MSI AppSearch action on DrLocator table always returns absolute paths.
8579  * If a relative path was set, it returns the first absolute path that
8580  * matches or an empty string if it didn't find anything.
8581  * This helper function replicates this behaviour.
8582  */
8583 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
8584 {
8585     int i, size;
8586     DWORD attr, drives;
8587
8588     size = lstrlenA(relative);
8589     drives = GetLogicalDrives();
8590     lstrcpyA(absolute, "A:\\");
8591     for (i = 0; i < 26; absolute[0] = '\0', i++)
8592     {
8593         if (!(drives & (1 << i)))
8594             continue;
8595
8596         absolute[0] = 'A' + i;
8597         if (GetDriveType(absolute) != DRIVE_FIXED)
8598             continue;
8599
8600         lstrcpynA(absolute + 3, relative, size + 1);
8601         attr = GetFileAttributesA(absolute);
8602         if (attr != INVALID_FILE_ATTRIBUTES &&
8603             (attr & FILE_ATTRIBUTE_DIRECTORY))
8604         {
8605             if (absolute[3 + size - 1] != '\\')
8606                 lstrcatA(absolute, "\\");
8607             break;
8608         }
8609         absolute[3] = '\0';
8610     }
8611 }
8612
8613 static void test_appsearch_drlocator(void)
8614 {
8615     MSIHANDLE hpkg, hdb;
8616     CHAR path[MAX_PATH];
8617     CHAR prop[MAX_PATH];
8618     BOOL version;
8619     LPCSTR str;
8620     DWORD size;
8621     UINT r;
8622
8623     version = TRUE;
8624     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8625         version = FALSE;
8626
8627     DeleteFileA("test.dll");
8628
8629     create_test_file("FileName1");
8630     CreateDirectoryA("one", NULL);
8631     CreateDirectoryA("one\\two", NULL);
8632     CreateDirectoryA("one\\two\\three", NULL);
8633     create_test_file("one\\two\\three\\FileName2");
8634     CreateDirectoryA("another", NULL);
8635     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8636     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8637     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8638
8639     hdb = create_package_db();
8640     ok(hdb, "Expected a valid database handle\n");
8641
8642     r = create_appsearch_table(hdb);
8643     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8644
8645     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8647
8648     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8649     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8650
8651     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8652     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8653
8654     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8655     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8656
8657     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8659
8660     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8661     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8662
8663     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8665
8666     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8667     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8668
8669     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8671
8672     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8674
8675     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8676     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8677
8678     r = create_drlocator_table(hdb);
8679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8680
8681     /* no parent, full path, depth 0, signature */
8682     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
8683     r = add_drlocator_entry(hdb, path);
8684     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8685
8686     /* no parent, full path, depth 0, no signature */
8687     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
8688     r = add_drlocator_entry(hdb, path);
8689     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8690
8691     /* no parent, relative path, depth 0, no signature */
8692     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
8693     r = add_drlocator_entry(hdb, path);
8694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8695
8696     /* no parent, full path, depth 2, signature */
8697     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
8698     r = add_drlocator_entry(hdb, path);
8699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8700
8701     /* no parent, full path, depth 3, signature */
8702     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
8703     r = add_drlocator_entry(hdb, path);
8704     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8705
8706     /* no parent, full path, depth 1, signature is dir */
8707     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
8708     r = add_drlocator_entry(hdb, path);
8709     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8710
8711     /* parent is in DrLocator, relative path, depth 0, signature */
8712     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
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, signature w/ version */
8717     sprintf(path, "'NewSignature8', '', '%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, full path, depth 0, signature w/ version, ver > max */
8722     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
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 0, signature w/ version, sig->name not ignored */
8727     sprintf(path, "'NewSignature10', '', '%s', 0", 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, relative empty path, depth 0, no signature */
8732     sprintf(path, "'NewSignature11', '', '', 0");
8733     r = add_drlocator_entry(hdb, path);
8734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8735
8736     r = create_signature_table(hdb);
8737     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8738
8739     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
8740     r = add_signature_entry(hdb, str);
8741     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8742
8743     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
8744     r = add_signature_entry(hdb, str);
8745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8746
8747     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
8748     r = add_signature_entry(hdb, str);
8749     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8750
8751     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
8752     r = add_signature_entry(hdb, str);
8753     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8754
8755     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
8756     r = add_signature_entry(hdb, str);
8757     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8758
8759     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8760     r = add_signature_entry(hdb, str);
8761     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8762
8763     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8764     r = add_signature_entry(hdb, str);
8765     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8766
8767     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8768     r = add_signature_entry(hdb, str);
8769     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8770
8771     hpkg = package_from_db(hdb);
8772     ok(hpkg, "Expected a valid package handle\n");
8773
8774     r = MsiDoAction(hpkg, "AppSearch");
8775     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8776
8777     size = MAX_PATH;
8778     sprintf(path, "%s\\FileName1", CURR_DIR);
8779     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8780     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8781     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8782
8783     size = MAX_PATH;
8784     sprintf(path, "%s\\", CURR_DIR);
8785     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8786     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8787     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8788
8789     size = MAX_PATH;
8790     search_absolute_directory(path, CURR_DIR + 3);
8791     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8793     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8794
8795     size = MAX_PATH;
8796     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8797     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8798     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8799
8800     size = MAX_PATH;
8801     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
8802     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8803     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8804     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8805
8806     size = MAX_PATH;
8807     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8808     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8809     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8810
8811     size = MAX_PATH;
8812     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
8813     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8815     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8816
8817     if (version)
8818     {
8819         size = MAX_PATH;
8820         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8821         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8822         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8823         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8824
8825         size = MAX_PATH;
8826         r = MsiGetPropertyA(hpkg, "SIGPROP9", 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         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8832         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8833         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8834     }
8835
8836     size = MAX_PATH;
8837     search_absolute_directory(path, "");
8838     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8839     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8840     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8841
8842     DeleteFileA("FileName1");
8843     DeleteFileA("FileName3.dll");
8844     DeleteFileA("FileName4.dll");
8845     DeleteFileA("FileName5.dll");
8846     DeleteFileA("one\\two\\three\\FileName2");
8847     RemoveDirectoryA("one\\two\\three");
8848     RemoveDirectoryA("one\\two");
8849     RemoveDirectoryA("one");
8850     RemoveDirectoryA("another");
8851     MsiCloseHandle(hpkg);
8852     DeleteFileA(msifile);
8853 }
8854
8855 static void test_featureparents(void)
8856 {
8857     MSIHANDLE hpkg;
8858     UINT r;
8859     MSIHANDLE hdb;
8860     INSTALLSTATE state, action;
8861
8862     hdb = create_package_db();
8863     ok ( hdb, "failed to create package database\n" );
8864
8865     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
8866     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
8867
8868     r = create_feature_table( hdb );
8869     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
8870
8871     r = create_component_table( hdb );
8872     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
8873
8874     r = create_feature_components_table( hdb );
8875     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
8876
8877     r = create_file_table( hdb );
8878     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
8879
8880     /* msidbFeatureAttributesFavorLocal */
8881     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
8882     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8883
8884     /* msidbFeatureAttributesFavorSource */
8885     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
8886     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8887
8888     /* msidbFeatureAttributesFavorLocal */
8889     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
8890     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8891
8892     /* disabled because of install level */
8893     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
8894     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8895
8896     /* child feature of disabled feature */
8897     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
8898     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
8899
8900     /* component of disabled feature (install level) */
8901     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
8902     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8903
8904     /* component of disabled child feature (install level) */
8905     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
8906     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8907
8908     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
8909     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
8910     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8911
8912     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
8913     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
8914     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8915
8916     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
8917     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
8918     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8919
8920     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
8921     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
8922     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8923
8924     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
8925     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
8926     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8927
8928     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
8929     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
8930     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8931
8932     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
8933     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
8934     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8935
8936     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
8937     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
8938     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
8939
8940     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
8941     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
8942
8943     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
8944     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8945
8946     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
8947     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8948
8949     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
8950     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8951
8952     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
8953     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8954
8955     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
8956     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8957
8958     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
8959     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8960
8961     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
8962     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8963
8964     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
8965     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8966
8967     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
8968     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8969
8970     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
8971     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8972
8973     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
8974     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8975
8976     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
8977     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8978
8979     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
8980     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8981
8982     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
8983     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8984
8985     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
8986     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8987
8988     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
8989     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8990
8991     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
8992     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
8993
8994     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
8995     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
8996
8997     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
8998     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
8999
9000     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9001     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9002
9003     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9004     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9005
9006     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9007     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9008
9009     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9010     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9011
9012     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9013     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9014
9015     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9016     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9017
9018     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9019     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9020
9021     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9022     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9023
9024     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9025     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9026
9027     hpkg = package_from_db( hdb );
9028     ok( hpkg, "failed to create package\n");
9029
9030     MsiCloseHandle( hdb );
9031
9032     r = MsiDoAction( hpkg, "CostInitialize");
9033     ok( r == ERROR_SUCCESS, "cost init failed\n");
9034
9035     r = MsiDoAction( hpkg, "FileCost");
9036     ok( r == ERROR_SUCCESS, "file cost failed\n");
9037
9038     r = MsiDoAction( hpkg, "CostFinalize");
9039     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9040
9041     state = 0xdeadbee;
9042     action = 0xdeadbee;
9043     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9045     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9046     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9047
9048     state = 0xdeadbee;
9049     action = 0xdeadbee;
9050     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9052     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9053     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9054
9055     state = 0xdeadbee;
9056     action = 0xdeadbee;
9057     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9059     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9060     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9061
9062     state = 0xdeadbee;
9063     action = 0xdeadbee;
9064     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9066     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9067     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9068
9069     state = 0xdeadbee;
9070     action = 0xdeadbee;
9071     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9072     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9073     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9074     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9075
9076     state = 0xdeadbee;
9077     action = 0xdeadbee;
9078     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9079     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9080     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9081     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9082
9083     state = 0xdeadbee;
9084     action = 0xdeadbee;
9085     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9086     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9087     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9088     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9089
9090     state = 0xdeadbee;
9091     action = 0xdeadbee;
9092     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9093     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9094     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9095     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9096
9097     state = 0xdeadbee;
9098     action = 0xdeadbee;
9099     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9101     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9102     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9103
9104     state = 0xdeadbee;
9105     action = 0xdeadbee;
9106     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9108     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9109     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9110
9111     state = 0xdeadbee;
9112     action = 0xdeadbee;
9113     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9115     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9116     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9117
9118     state = 0xdeadbee;
9119     action = 0xdeadbee;
9120     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9122     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9123     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9124
9125     state = 0xdeadbee;
9126     action = 0xdeadbee;
9127     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9129     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9130     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9131
9132     state = 0xdeadbee;
9133     action = 0xdeadbee;
9134     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9136     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9137     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9138
9139     state = 0xdeadbee;
9140     action = 0xdeadbee;
9141     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9143     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9144     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9145
9146     state = 0xdeadbee;
9147     action = 0xdeadbee;
9148     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9150     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9151     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9152
9153     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9154     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9155
9156     state = 0xdeadbee;
9157     action = 0xdeadbee;
9158     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9160     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9161     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9162
9163     state = 0xdeadbee;
9164     action = 0xdeadbee;
9165     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9167     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9168     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9169
9170     state = 0xdeadbee;
9171     action = 0xdeadbee;
9172     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9174     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9175     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9176
9177     state = 0xdeadbee;
9178     action = 0xdeadbee;
9179     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9181     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9182     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9183
9184     state = 0xdeadbee;
9185     action = 0xdeadbee;
9186     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9188     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9189     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9190
9191     state = 0xdeadbee;
9192     action = 0xdeadbee;
9193     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9195     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9196     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9197
9198     state = 0xdeadbee;
9199     action = 0xdeadbee;
9200     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9202     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9203     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9204
9205     state = 0xdeadbee;
9206     action = 0xdeadbee;
9207     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9209     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9210     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9211
9212     state = 0xdeadbee;
9213     action = 0xdeadbee;
9214     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9216     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9217     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9218
9219     state = 0xdeadbee;
9220     action = 0xdeadbee;
9221     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9223     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9224     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9225
9226     state = 0xdeadbee;
9227     action = 0xdeadbee;
9228     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9230     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9231     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9232
9233     state = 0xdeadbee;
9234     action = 0xdeadbee;
9235     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9237     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9238     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9239
9240     state = 0xdeadbee;
9241     action = 0xdeadbee;
9242     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9243     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9244     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9245     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9246
9247     state = 0xdeadbee;
9248     action = 0xdeadbee;
9249     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9250     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9251     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9252     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9253     
9254     MsiCloseHandle(hpkg);
9255     DeleteFileA(msifile);
9256 }
9257
9258 static void test_installprops(void)
9259 {
9260     MSIHANDLE hpkg, hdb;
9261     CHAR path[MAX_PATH];
9262     CHAR buf[MAX_PATH];
9263     DWORD size, type;
9264     LANGID langid;
9265     HKEY hkey1, hkey2;
9266     int res;
9267     UINT r;
9268
9269     GetCurrentDirectory(MAX_PATH, path);
9270     lstrcat(path, "\\");
9271     lstrcat(path, msifile);
9272
9273     hdb = create_package_db();
9274     ok( hdb, "failed to create database\n");
9275
9276     hpkg = package_from_db(hdb);
9277     ok( hpkg, "failed to create package\n");
9278
9279     MsiCloseHandle(hdb);
9280
9281     size = MAX_PATH;
9282     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
9283     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9284     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9285
9286     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
9287
9288     RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
9289
9290     size = MAX_PATH;
9291     type = REG_SZ;
9292     *path = '\0';
9293     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9294     {
9295         size = MAX_PATH;
9296         type = REG_SZ;
9297         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
9298     }
9299
9300     /* win9x doesn't set this */
9301     if (*path)
9302     {
9303         size = MAX_PATH;
9304         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
9305         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9306         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9307     }
9308
9309     size = MAX_PATH;
9310     type = REG_SZ;
9311     *path = '\0';
9312     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9313     {
9314         size = MAX_PATH;
9315         type = REG_SZ;
9316         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
9317     }
9318
9319     if (*path)
9320     {
9321         size = MAX_PATH;
9322         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
9323         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9324         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9325     }
9326
9327     size = MAX_PATH;
9328     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
9329     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9330     trace("VersionDatabase = %s\n", buf);
9331
9332     size = MAX_PATH;
9333     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
9334     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9335     trace("VersionMsi = %s\n", buf);
9336
9337     size = MAX_PATH;
9338     r = MsiGetProperty(hpkg, "Date", buf, &size);
9339     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9340     trace("Date = %s\n", buf);
9341
9342     size = MAX_PATH;
9343     r = MsiGetProperty(hpkg, "Time", buf, &size);
9344     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9345     trace("Time = %s\n", buf);
9346
9347     size = MAX_PATH;
9348     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
9349     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9350     trace("PackageCode = %s\n", buf);
9351
9352     langid = GetUserDefaultLangID();
9353     sprintf(path, "%d", langid);
9354
9355     size = MAX_PATH;
9356     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
9357     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
9358     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
9359
9360     res = GetSystemMetrics(SM_CXSCREEN);
9361     size = MAX_PATH;
9362     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
9363     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9364
9365     res = GetSystemMetrics(SM_CYSCREEN);
9366     size = MAX_PATH;
9367     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
9368     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9369
9370     CloseHandle(hkey1);
9371     CloseHandle(hkey2);
9372     MsiCloseHandle(hpkg);
9373     DeleteFile(msifile);
9374 }
9375
9376 static void test_launchconditions(void)
9377 {
9378     MSIHANDLE hpkg;
9379     MSIHANDLE hdb;
9380     UINT r;
9381
9382     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9383
9384     hdb = create_package_db();
9385     ok( hdb, "failed to create package database\n" );
9386
9387     r = create_launchcondition_table( hdb );
9388     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
9389
9390     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
9391     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9392
9393     /* invalid condition */
9394     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
9395     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9396
9397     hpkg = package_from_db( hdb );
9398     ok( hpkg, "failed to create package\n");
9399
9400     MsiCloseHandle( hdb );
9401
9402     r = MsiSetProperty( hpkg, "X", "1" );
9403     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9404
9405     /* invalid conditions are ignored */
9406     r = MsiDoAction( hpkg, "LaunchConditions" );
9407     ok( r == ERROR_SUCCESS, "cost init failed\n" );
9408
9409     /* verify LaunchConditions still does some verification */
9410     r = MsiSetProperty( hpkg, "X", "2" );
9411     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9412
9413     r = MsiDoAction( hpkg, "LaunchConditions" );
9414     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
9415
9416     MsiCloseHandle( hpkg );
9417     DeleteFile( msifile );
9418 }
9419
9420 static void test_ccpsearch(void)
9421 {
9422     MSIHANDLE hdb, hpkg;
9423     CHAR prop[MAX_PATH];
9424     DWORD size = MAX_PATH;
9425     UINT r;
9426
9427     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9428
9429     hdb = create_package_db();
9430     ok(hdb, "failed to create package database\n");
9431
9432     r = create_ccpsearch_table(hdb);
9433     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9434
9435     r = add_ccpsearch_entry(hdb, "'CCP_random'");
9436     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9437
9438     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
9439     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9440
9441     r = create_reglocator_table(hdb);
9442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9443
9444     r = add_reglocator_entry(hdb, "'CCP_random', 0, 'htmlfile\\shell\\open\\nonexistent', '', 1");
9445     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9446
9447     r = create_drlocator_table(hdb);
9448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9449
9450     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
9451     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9452
9453     r = create_signature_table(hdb);
9454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9455
9456     hpkg = package_from_db(hdb);
9457     ok(hpkg, "failed to create package\n");
9458
9459     MsiCloseHandle(hdb);
9460
9461     r = MsiDoAction(hpkg, "CCPSearch");
9462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9463
9464     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
9465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9466     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
9467
9468     MsiCloseHandle(hpkg);
9469     DeleteFileA(msifile);
9470 }
9471
9472 static void test_complocator(void)
9473 {
9474     MSIHANDLE hdb, hpkg;
9475     UINT r;
9476     CHAR prop[MAX_PATH];
9477     CHAR expected[MAX_PATH];
9478     DWORD size = MAX_PATH;
9479
9480     hdb = create_package_db();
9481     ok(hdb, "failed to create package database\n");
9482
9483     r = create_appsearch_table(hdb);
9484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9485
9486     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
9487     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9488
9489     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
9490     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9491
9492     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
9493     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9494
9495     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
9496     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9497
9498     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
9499     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9500
9501     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
9502     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9503
9504     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
9505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9506
9507     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
9508     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9509
9510     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
9511     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9512
9513     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
9514     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9515
9516     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
9517     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9518
9519     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
9520     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9521
9522     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
9523     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9524
9525     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
9526     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9527
9528     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
9529     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9530
9531     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
9532     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9533
9534     r = create_complocator_table(hdb);
9535     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9536
9537     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
9538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9539
9540     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
9541     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9542
9543     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
9544     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9545
9546     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
9547     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9548
9549     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
9550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9551
9552     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
9553     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9554
9555     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
9556     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9557
9558     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
9559     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9560
9561     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
9562     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9563
9564     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
9565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9566
9567     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
9568     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9569
9570     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
9571     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9572
9573     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
9574     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9575
9576     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
9577     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9578
9579     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
9580     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9581
9582     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
9583     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9584
9585     r = create_signature_table(hdb);
9586     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9587
9588     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
9589     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9590
9591     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
9592     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9593
9594     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
9595     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9596
9597     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
9598     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9599
9600     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
9601     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9602
9603     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
9604     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9605
9606     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
9607     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9608
9609     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
9610     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9611
9612     hpkg = package_from_db(hdb);
9613     ok(hpkg, "failed to create package\n");
9614
9615     MsiCloseHandle(hdb);
9616
9617     create_test_file("abelisaurus");
9618     create_test_file("bactrosaurus");
9619     create_test_file("camelotia");
9620     create_test_file("diclonius");
9621     create_test_file("echinodon");
9622     create_test_file("falcarius");
9623     create_test_file("gallimimus");
9624     create_test_file("hagryphus");
9625     CreateDirectoryA("iguanodon", NULL);
9626     CreateDirectoryA("jobaria", NULL);
9627     CreateDirectoryA("kakuru", NULL);
9628     CreateDirectoryA("labocania", NULL);
9629     CreateDirectoryA("megaraptor", NULL);
9630     CreateDirectoryA("neosodon", NULL);
9631     CreateDirectoryA("olorotitan", NULL);
9632     CreateDirectoryA("pantydraco", NULL);
9633
9634     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
9635                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
9636     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
9637                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
9638     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
9639                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
9640     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
9641                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
9642     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
9643                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
9644     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
9645                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
9646     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
9647                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
9648     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
9649                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
9650
9651     r = MsiDoAction(hpkg, "AppSearch");
9652     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9653
9654     size = MAX_PATH;
9655     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
9656     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9657
9658     lstrcpyA(expected, CURR_DIR);
9659     lstrcatA(expected, "\\abelisaurus");
9660     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9661        "Expected %s or empty string, got %s\n", expected, prop);
9662
9663     size = MAX_PATH;
9664     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
9665     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9666     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9667
9668     size = MAX_PATH;
9669     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
9670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9671     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9672
9673     size = MAX_PATH;
9674     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
9675     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9676     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9677
9678     size = MAX_PATH;
9679     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
9680     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9681
9682     lstrcpyA(expected, CURR_DIR);
9683     lstrcatA(expected, "\\");
9684     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9685        "Expected %s or empty string, got %s\n", expected, prop);
9686
9687     size = MAX_PATH;
9688     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
9689     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9690     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9691
9692     size = MAX_PATH;
9693     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
9694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9695     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9696
9697     size = MAX_PATH;
9698     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
9699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9700     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9701
9702     size = MAX_PATH;
9703     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
9704     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9705     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9706
9707     size = MAX_PATH;
9708     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
9709     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9710     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9711
9712     size = MAX_PATH;
9713     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
9714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9715     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9716
9717     size = MAX_PATH;
9718     r = MsiGetPropertyA(hpkg, "LABOCANIA", 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, "MEGARAPTOR", prop, &size);
9724     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9725
9726     lstrcpyA(expected, CURR_DIR);
9727     lstrcatA(expected, "\\");
9728     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9729        "Expected %s or empty string, got %s\n", expected, prop);
9730
9731     size = MAX_PATH;
9732     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
9733     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9734
9735     lstrcpyA(expected, CURR_DIR);
9736     lstrcatA(expected, "\\neosodon\\");
9737     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9738        "Expected %s or empty string, got %s\n", expected, prop);
9739
9740     size = MAX_PATH;
9741     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
9742     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9743     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9744
9745     size = MAX_PATH;
9746     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
9747     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9748     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9749
9750     MsiCloseHandle(hpkg);
9751     DeleteFileA("abelisaurus");
9752     DeleteFileA("bactrosaurus");
9753     DeleteFileA("camelotia");
9754     DeleteFileA("diclonius");
9755     DeleteFileA("echinodon");
9756     DeleteFileA("falcarius");
9757     DeleteFileA("gallimimus");
9758     DeleteFileA("hagryphus");
9759     RemoveDirectoryA("iguanodon");
9760     RemoveDirectoryA("jobaria");
9761     RemoveDirectoryA("kakuru");
9762     RemoveDirectoryA("labocania");
9763     RemoveDirectoryA("megaraptor");
9764     RemoveDirectoryA("neosodon");
9765     RemoveDirectoryA("olorotitan");
9766     RemoveDirectoryA("pantydraco");
9767     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
9768                           MSIINSTALLCONTEXT_MACHINE, NULL);
9769     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
9770                           MSIINSTALLCONTEXT_MACHINE, NULL);
9771     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
9772                           MSIINSTALLCONTEXT_MACHINE, NULL);
9773     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
9774                           MSIINSTALLCONTEXT_MACHINE, NULL);
9775     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
9776                           MSIINSTALLCONTEXT_MACHINE, NULL);
9777     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
9778                           MSIINSTALLCONTEXT_MACHINE, NULL);
9779     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
9780                           MSIINSTALLCONTEXT_MACHINE, NULL);
9781     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
9782                           MSIINSTALLCONTEXT_MACHINE, NULL);
9783     DeleteFileA(msifile);
9784 }
9785
9786 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
9787 {
9788     MSIHANDLE summary;
9789     UINT r;
9790
9791     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
9792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9793
9794     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
9795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9796
9797     r = MsiSummaryInfoPersist(summary);
9798     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9799
9800     MsiCloseHandle(summary);
9801 }
9802
9803 static void test_MsiGetSourcePath(void)
9804 {
9805     MSIHANDLE hdb, hpkg;
9806     CHAR path[MAX_PATH];
9807     CHAR cwd[MAX_PATH];
9808     CHAR subsrc[MAX_PATH];
9809     CHAR sub2[MAX_PATH];
9810     DWORD size;
9811     UINT r;
9812
9813     lstrcpyA(cwd, CURR_DIR);
9814     lstrcatA(cwd, "\\");
9815
9816     lstrcpyA(subsrc, cwd);
9817     lstrcatA(subsrc, "subsource");
9818     lstrcatA(subsrc, "\\");
9819
9820     lstrcpyA(sub2, subsrc);
9821     lstrcatA(sub2, "sub2");
9822     lstrcatA(sub2, "\\");
9823
9824     /* uncompressed source */
9825
9826     hdb = create_package_db();
9827     ok( hdb, "failed to create database\n");
9828
9829     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
9830
9831     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
9832     ok(r == S_OK, "failed\n");
9833
9834     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
9835     ok(r == S_OK, "failed\n");
9836
9837     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
9838     ok(r == S_OK, "failed\n");
9839
9840     r = MsiDatabaseCommit(hdb);
9841     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
9842
9843     hpkg = package_from_db(hdb);
9844     ok(hpkg, "failed to create package\n");
9845
9846     MsiCloseHandle(hdb);
9847
9848     /* invalid database handle */
9849     size = MAX_PATH;
9850     lstrcpyA(path, "kiwi");
9851     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
9852     ok(r == ERROR_INVALID_HANDLE,
9853        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
9854     ok(!lstrcmpA(path, "kiwi"),
9855        "Expected path to be unchanged, got \"%s\"\n", path);
9856     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9857
9858     /* NULL szFolder */
9859     size = MAX_PATH;
9860     lstrcpyA(path, "kiwi");
9861     r = MsiGetSourcePath(hpkg, NULL, path, &size);
9862     ok(r == ERROR_INVALID_PARAMETER,
9863        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9864     ok(!lstrcmpA(path, "kiwi"),
9865        "Expected path to be unchanged, got \"%s\"\n", path);
9866     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9867
9868     /* empty szFolder */
9869     size = MAX_PATH;
9870     lstrcpyA(path, "kiwi");
9871     r = MsiGetSourcePath(hpkg, "", path, &size);
9872     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9873     ok(!lstrcmpA(path, "kiwi"),
9874        "Expected path to be unchanged, got \"%s\"\n", path);
9875     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9876
9877     /* try TARGETDIR */
9878     size = MAX_PATH;
9879     lstrcpyA(path, "kiwi");
9880     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
9881     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9882     ok(!lstrcmpA(path, "kiwi"),
9883        "Expected path to be unchanged, got \"%s\"\n", path);
9884     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9885
9886     /* try SourceDir */
9887     size = MAX_PATH;
9888     lstrcpyA(path, "kiwi");
9889     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
9890     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9891     ok(!lstrcmpA(path, "kiwi"),
9892        "Expected path to be unchanged, got \"%s\"\n", path);
9893     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9894
9895     /* try SOURCEDIR */
9896     size = MAX_PATH;
9897     lstrcpyA(path, "kiwi");
9898     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9899     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9900     ok(!lstrcmpA(path, "kiwi"),
9901        "Expected path to be unchanged, got \"%s\"\n", path);
9902     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9903
9904     /* source path does not exist, but the property exists */
9905     size = MAX_PATH;
9906     lstrcpyA(path, "kiwi");
9907     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9908     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9909     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9910     ok(size == 0, "Expected 0, got %d\n", size);
9911
9912     /* try SubDir */
9913     size = MAX_PATH;
9914     lstrcpyA(path, "kiwi");
9915     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
9916     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9917     ok(!lstrcmpA(path, "kiwi"),
9918        "Expected path to be unchanged, got \"%s\"\n", path);
9919     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9920
9921     /* try SubDir2 */
9922     size = MAX_PATH;
9923     lstrcpyA(path, "kiwi");
9924     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
9925     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9926     ok(!lstrcmpA(path, "kiwi"),
9927        "Expected path to be unchanged, got \"%s\"\n", path);
9928     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9929
9930     r = MsiDoAction(hpkg, "CostInitialize");
9931     ok(r == ERROR_SUCCESS, "cost init failed\n");
9932
9933     /* try TARGETDIR after CostInitialize */
9934     size = MAX_PATH;
9935     lstrcpyA(path, "kiwi");
9936     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
9937     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9938     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9939     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9940
9941     /* try SourceDir after CostInitialize */
9942     size = MAX_PATH;
9943     lstrcpyA(path, "kiwi");
9944     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
9945     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9946     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9947     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9948
9949     /* try SOURCEDIR after CostInitialize */
9950     size = MAX_PATH;
9951     lstrcpyA(path, "kiwi");
9952     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9953     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9954     ok(!lstrcmpA(path, "kiwi"),
9955        "Expected path to be unchanged, got \"%s\"\n", path);
9956     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9957
9958     /* source path does not exist, but the property exists */
9959     size = MAX_PATH;
9960     lstrcpyA(path, "kiwi");
9961     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9962     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9963     todo_wine
9964     {
9965         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9966         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9967     }
9968
9969     /* try SubDir after CostInitialize */
9970     size = MAX_PATH;
9971     lstrcpyA(path, "kiwi");
9972     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
9973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9974     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
9975     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
9976
9977     /* try SubDir2 after CostInitialize */
9978     size = MAX_PATH;
9979     lstrcpyA(path, "kiwi");
9980     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
9981     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9982     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
9983     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
9984
9985     r = MsiDoAction(hpkg, "ResolveSource");
9986     ok(r == ERROR_SUCCESS, "file cost failed\n");
9987
9988     /* try TARGETDIR after ResolveSource */
9989     size = MAX_PATH;
9990     lstrcpyA(path, "kiwi");
9991     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
9992     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9993     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9994     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9995
9996     /* try SourceDir after ResolveSource */
9997     size = MAX_PATH;
9998     lstrcpyA(path, "kiwi");
9999     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10001     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10002     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10003
10004     /* try SOURCEDIR after ResolveSource */
10005     size = MAX_PATH;
10006     lstrcpyA(path, "kiwi");
10007     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10008     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10009     ok(!lstrcmpA(path, "kiwi"),
10010        "Expected path to be unchanged, got \"%s\"\n", path);
10011     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10012
10013     /* source path does not exist, but the property exists */
10014     size = MAX_PATH;
10015     lstrcpyA(path, "kiwi");
10016     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10017     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10018     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10019     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10020
10021     /* try SubDir after ResolveSource */
10022     size = MAX_PATH;
10023     lstrcpyA(path, "kiwi");
10024     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10025     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10026     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10027     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10028
10029     /* try SubDir2 after ResolveSource */
10030     size = MAX_PATH;
10031     lstrcpyA(path, "kiwi");
10032     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10034     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10035     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10036
10037     r = MsiDoAction(hpkg, "FileCost");
10038     ok(r == ERROR_SUCCESS, "file cost failed\n");
10039
10040     /* try TARGETDIR after FileCost */
10041     size = MAX_PATH;
10042     lstrcpyA(path, "kiwi");
10043     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10045     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10046     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10047
10048     /* try SourceDir after FileCost */
10049     size = MAX_PATH;
10050     lstrcpyA(path, "kiwi");
10051     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10052     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10053     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10054     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10055
10056     /* try SOURCEDIR after FileCost */
10057     size = MAX_PATH;
10058     lstrcpyA(path, "kiwi");
10059     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10060     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10061     ok(!lstrcmpA(path, "kiwi"),
10062        "Expected path to be unchanged, got \"%s\"\n", path);
10063     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10064
10065     /* source path does not exist, but the property exists */
10066     size = MAX_PATH;
10067     lstrcpyA(path, "kiwi");
10068     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10070     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10071     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10072
10073     /* try SubDir after FileCost */
10074     size = MAX_PATH;
10075     lstrcpyA(path, "kiwi");
10076     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10078     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10079     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10080
10081     /* try SubDir2 after FileCost */
10082     size = MAX_PATH;
10083     lstrcpyA(path, "kiwi");
10084     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10085     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10086     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10087     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10088
10089     r = MsiDoAction(hpkg, "CostFinalize");
10090     ok(r == ERROR_SUCCESS, "file cost failed\n");
10091
10092     /* try TARGETDIR after CostFinalize */
10093     size = MAX_PATH;
10094     lstrcpyA(path, "kiwi");
10095     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10096     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10097     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10098     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10099
10100     /* try SourceDir after CostFinalize */
10101     size = MAX_PATH;
10102     lstrcpyA(path, "kiwi");
10103     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10104     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10105     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10106     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10107
10108     /* try SOURCEDIR after CostFinalize */
10109     size = MAX_PATH;
10110     lstrcpyA(path, "kiwi");
10111     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10112     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10113     ok(!lstrcmpA(path, "kiwi"),
10114        "Expected path to be unchanged, got \"%s\"\n", path);
10115     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10116
10117     /* source path does not exist, but the property exists */
10118     size = MAX_PATH;
10119     lstrcpyA(path, "kiwi");
10120     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10121     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10122     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10123     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10124
10125     /* try SubDir after CostFinalize */
10126     size = MAX_PATH;
10127     lstrcpyA(path, "kiwi");
10128     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10130     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10131     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10132
10133     /* try SubDir2 after CostFinalize */
10134     size = MAX_PATH;
10135     lstrcpyA(path, "kiwi");
10136     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10138     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10139     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10140
10141     /* nonexistent directory */
10142     size = MAX_PATH;
10143     lstrcpyA(path, "kiwi");
10144     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
10145     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10146     ok(!lstrcmpA(path, "kiwi"),
10147        "Expected path to be unchanged, got \"%s\"\n", path);
10148     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10149
10150     /* NULL szPathBuf */
10151     size = MAX_PATH;
10152     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
10153     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10154     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10155
10156     /* NULL pcchPathBuf */
10157     lstrcpyA(path, "kiwi");
10158     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
10159     ok(r == ERROR_INVALID_PARAMETER,
10160        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10161     ok(!lstrcmpA(path, "kiwi"),
10162        "Expected path to be unchanged, got \"%s\"\n", path);
10163
10164     /* pcchPathBuf is 0 */
10165     size = 0;
10166     lstrcpyA(path, "kiwi");
10167     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10168     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10169     ok(!lstrcmpA(path, "kiwi"),
10170        "Expected path to be unchanged, got \"%s\"\n", path);
10171     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10172
10173     /* pcchPathBuf does not have room for NULL terminator */
10174     size = lstrlenA(cwd);
10175     lstrcpyA(path, "kiwi");
10176     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10177     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10178     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
10179        "Expected path with no backslash, got \"%s\"\n", path);
10180     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10181
10182     /* pcchPathBuf has room for NULL terminator */
10183     size = lstrlenA(cwd) + 1;
10184     lstrcpyA(path, "kiwi");
10185     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10186     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10187     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10188     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10189
10190     MsiCloseHandle(hpkg);
10191
10192     /* compressed source */
10193
10194     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
10195     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10196
10197     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
10198
10199     hpkg = package_from_db(hdb);
10200     ok(hpkg, "failed to create package\n");
10201
10202     /* try TARGETDIR */
10203     size = MAX_PATH;
10204     lstrcpyA(path, "kiwi");
10205     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10206     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10207     ok(!lstrcmpA(path, "kiwi"),
10208        "Expected path to be unchanged, got \"%s\"\n", path);
10209     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10210
10211     /* try SourceDir */
10212     size = MAX_PATH;
10213     lstrcpyA(path, "kiwi");
10214     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10215     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10216     ok(!lstrcmpA(path, "kiwi"),
10217        "Expected path to be unchanged, got \"%s\"\n", path);
10218     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10219
10220     /* try SOURCEDIR */
10221     size = MAX_PATH;
10222     lstrcpyA(path, "kiwi");
10223     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10224     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10225     ok(!lstrcmpA(path, "kiwi"),
10226        "Expected path to be unchanged, got \"%s\"\n", path);
10227     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10228
10229     /* source path nor the property exist */
10230     size = MAX_PATH;
10231     lstrcpyA(path, "kiwi");
10232     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10233     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10234     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10235     ok(size == 0, "Expected 0, got %d\n", size);
10236
10237     /* try SubDir */
10238     size = MAX_PATH;
10239     lstrcpyA(path, "kiwi");
10240     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10241     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10242     ok(!lstrcmpA(path, "kiwi"),
10243        "Expected path to be unchanged, got \"%s\"\n", path);
10244     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10245
10246     /* try SubDir2 */
10247     size = MAX_PATH;
10248     lstrcpyA(path, "kiwi");
10249     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10250     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10251     ok(!lstrcmpA(path, "kiwi"),
10252        "Expected path to be unchanged, got \"%s\"\n", path);
10253     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10254
10255     r = MsiDoAction(hpkg, "CostInitialize");
10256     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10257
10258     /* try TARGETDIR after CostInitialize */
10259     size = MAX_PATH;
10260     lstrcpyA(path, "kiwi");
10261     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10262     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10263     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10264     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10265
10266     /* try SourceDir after CostInitialize */
10267     size = MAX_PATH;
10268     lstrcpyA(path, "kiwi");
10269     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10270     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10271     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10272     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10273
10274     /* try SOURCEDIR after CostInitialize */
10275     size = MAX_PATH;
10276     lstrcpyA(path, "kiwi");
10277     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10278     todo_wine
10279     {
10280         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10281         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10282         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10283     }
10284
10285     /* source path does not exist, but the property exists */
10286     size = MAX_PATH;
10287     lstrcpyA(path, "kiwi");
10288     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10289     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10290     todo_wine
10291     {
10292         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10293         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10294     }
10295
10296     /* try SubDir after CostInitialize */
10297     size = MAX_PATH;
10298     lstrcpyA(path, "kiwi");
10299     r = MsiGetSourcePath(hpkg, "SubDir", 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 SubDir2 after CostInitialize */
10305     size = MAX_PATH;
10306     lstrcpyA(path, "kiwi");
10307     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10308     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10309     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10310     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10311
10312     r = MsiDoAction(hpkg, "ResolveSource");
10313     ok(r == ERROR_SUCCESS, "file cost failed\n");
10314
10315     /* try TARGETDIR after ResolveSource */
10316     size = MAX_PATH;
10317     lstrcpyA(path, "kiwi");
10318     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10319     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10320     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10321     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10322
10323     /* try SourceDir after ResolveSource */
10324     size = MAX_PATH;
10325     lstrcpyA(path, "kiwi");
10326     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10327     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10328     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10329     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10330
10331     /* try SOURCEDIR after ResolveSource */
10332     size = MAX_PATH;
10333     lstrcpyA(path, "kiwi");
10334     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10335     todo_wine
10336     {
10337         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10338         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10339         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10340     }
10341
10342     /* source path and the property exist */
10343     size = MAX_PATH;
10344     lstrcpyA(path, "kiwi");
10345     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10346     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10347     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10348     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10349
10350     /* try SubDir after ResolveSource */
10351     size = MAX_PATH;
10352     lstrcpyA(path, "kiwi");
10353     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10354     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10355     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10356     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10357
10358     /* try SubDir2 after ResolveSource */
10359     size = MAX_PATH;
10360     lstrcpyA(path, "kiwi");
10361     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10362     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10363     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10364     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10365
10366     r = MsiDoAction(hpkg, "FileCost");
10367     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10368
10369     /* try TARGETDIR after CostFinalize */
10370     size = MAX_PATH;
10371     lstrcpyA(path, "kiwi");
10372     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10373     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10374     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10375     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10376
10377     /* try SourceDir after CostFinalize */
10378     size = MAX_PATH;
10379     lstrcpyA(path, "kiwi");
10380     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10381     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10382     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10383     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10384
10385     /* try SOURCEDIR after CostFinalize */
10386     size = MAX_PATH;
10387     lstrcpyA(path, "kiwi");
10388     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10389     todo_wine
10390     {
10391         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10392         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10393         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10394     }
10395
10396     /* source path and the property exist */
10397     size = MAX_PATH;
10398     lstrcpyA(path, "kiwi");
10399     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10400     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10401     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10402     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10403
10404     /* try SubDir after CostFinalize */
10405     size = MAX_PATH;
10406     lstrcpyA(path, "kiwi");
10407     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10409     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10410     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10411
10412     /* try SubDir2 after CostFinalize */
10413     size = MAX_PATH;
10414     lstrcpyA(path, "kiwi");
10415     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10417     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10418     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10419
10420     r = MsiDoAction(hpkg, "CostFinalize");
10421     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10422
10423     /* try TARGETDIR after CostFinalize */
10424     size = MAX_PATH;
10425     lstrcpyA(path, "kiwi");
10426     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10427     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10428     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10429     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10430
10431     /* try SourceDir after CostFinalize */
10432     size = MAX_PATH;
10433     lstrcpyA(path, "kiwi");
10434     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10436     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10437     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10438
10439     /* try SOURCEDIR after CostFinalize */
10440     size = MAX_PATH;
10441     lstrcpyA(path, "kiwi");
10442     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10443     todo_wine
10444     {
10445         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10446         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10447         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10448     }
10449
10450     /* source path and the property exist */
10451     size = MAX_PATH;
10452     lstrcpyA(path, "kiwi");
10453     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10455     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10456     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10457
10458     /* try SubDir after CostFinalize */
10459     size = MAX_PATH;
10460     lstrcpyA(path, "kiwi");
10461     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10463     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10464     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10465
10466     /* try SubDir2 after CostFinalize */
10467     size = MAX_PATH;
10468     lstrcpyA(path, "kiwi");
10469     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10470     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10471     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10472     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10473
10474     MsiCloseHandle(hpkg);
10475     DeleteFile(msifile);
10476 }
10477
10478 static void test_shortlongsource(void)
10479 {
10480     MSIHANDLE hdb, hpkg;
10481     CHAR path[MAX_PATH];
10482     CHAR cwd[MAX_PATH];
10483     CHAR subsrc[MAX_PATH];
10484     DWORD size;
10485     UINT r;
10486
10487     lstrcpyA(cwd, CURR_DIR);
10488     lstrcatA(cwd, "\\");
10489
10490     lstrcpyA(subsrc, cwd);
10491     lstrcatA(subsrc, "long");
10492     lstrcatA(subsrc, "\\");
10493
10494     /* long file names */
10495
10496     hdb = create_package_db();
10497     ok( hdb, "failed to create database\n");
10498
10499     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10500
10501     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10502     ok(r == S_OK, "failed\n");
10503
10504     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
10505     ok(r == S_OK, "failed\n");
10506
10507     /* CostInitialize:short */
10508     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
10509     ok(r == S_OK, "failed\n");
10510
10511     /* CostInitialize:long */
10512     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
10513     ok(r == S_OK, "failed\n");
10514
10515     /* FileCost:short */
10516     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
10517     ok(r == S_OK, "failed\n");
10518
10519     /* FileCost:long */
10520     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
10521     ok(r == S_OK, "failed\n");
10522
10523     /* CostFinalize:short */
10524     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
10525     ok(r == S_OK, "failed\n");
10526
10527     /* CostFinalize:long */
10528     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
10529     ok(r == S_OK, "failed\n");
10530
10531     MsiDatabaseCommit(hdb);
10532
10533     hpkg = package_from_db(hdb);
10534     ok(hpkg, "failed to create package\n");
10535
10536     MsiCloseHandle(hdb);
10537
10538     CreateDirectoryA("one", NULL);
10539     CreateDirectoryA("four", NULL);
10540
10541     r = MsiDoAction(hpkg, "CostInitialize");
10542     ok(r == ERROR_SUCCESS, "file cost failed\n");
10543
10544     CreateDirectory("five", NULL);
10545     CreateDirectory("eight", NULL);
10546
10547     r = MsiDoAction(hpkg, "FileCost");
10548     ok(r == ERROR_SUCCESS, "file cost failed\n");
10549
10550     CreateDirectory("nine", NULL);
10551     CreateDirectory("twelve", NULL);
10552
10553     r = MsiDoAction(hpkg, "CostFinalize");
10554     ok(r == ERROR_SUCCESS, "file cost failed\n");
10555
10556     /* neither short nor long source directories exist */
10557     size = MAX_PATH;
10558     lstrcpyA(path, "kiwi");
10559     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10560     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10561     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10562     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10563
10564     CreateDirectoryA("short", NULL);
10565
10566     /* short source directory exists */
10567     size = MAX_PATH;
10568     lstrcpyA(path, "kiwi");
10569     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10571     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10572     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10573
10574     CreateDirectoryA("long", NULL);
10575
10576     /* both short and long source directories exist */
10577     size = MAX_PATH;
10578     lstrcpyA(path, "kiwi");
10579     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10580     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10581     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10582     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10583
10584     lstrcpyA(subsrc, cwd);
10585     lstrcatA(subsrc, "two");
10586     lstrcatA(subsrc, "\\");
10587
10588     /* short dir exists before CostInitialize */
10589     size = MAX_PATH;
10590     lstrcpyA(path, "kiwi");
10591     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10592     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10593     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10594     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10595
10596     lstrcpyA(subsrc, cwd);
10597     lstrcatA(subsrc, "four");
10598     lstrcatA(subsrc, "\\");
10599
10600     /* long dir exists before CostInitialize */
10601     size = MAX_PATH;
10602     lstrcpyA(path, "kiwi");
10603     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
10604     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10605     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10606     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10607
10608     lstrcpyA(subsrc, cwd);
10609     lstrcatA(subsrc, "six");
10610     lstrcatA(subsrc, "\\");
10611
10612     /* short dir exists before FileCost */
10613     size = MAX_PATH;
10614     lstrcpyA(path, "kiwi");
10615     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
10616     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10617     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10618     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10619
10620     lstrcpyA(subsrc, cwd);
10621     lstrcatA(subsrc, "eight");
10622     lstrcatA(subsrc, "\\");
10623
10624     /* long dir exists before FileCost */
10625     size = MAX_PATH;
10626     lstrcpyA(path, "kiwi");
10627     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
10628     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10629     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10630     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10631
10632     lstrcpyA(subsrc, cwd);
10633     lstrcatA(subsrc, "ten");
10634     lstrcatA(subsrc, "\\");
10635
10636     /* short dir exists before CostFinalize */
10637     size = MAX_PATH;
10638     lstrcpyA(path, "kiwi");
10639     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
10640     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10641     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10642     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10643
10644     lstrcpyA(subsrc, cwd);
10645     lstrcatA(subsrc, "twelve");
10646     lstrcatA(subsrc, "\\");
10647
10648     /* long dir exists before CostFinalize */
10649     size = MAX_PATH;
10650     lstrcpyA(path, "kiwi");
10651     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
10652     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10653     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10654     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10655
10656     MsiCloseHandle(hpkg);
10657     RemoveDirectoryA("short");
10658     RemoveDirectoryA("long");
10659     RemoveDirectoryA("one");
10660     RemoveDirectoryA("four");
10661     RemoveDirectoryA("five");
10662     RemoveDirectoryA("eight");
10663     RemoveDirectoryA("nine");
10664     RemoveDirectoryA("twelve");
10665
10666     /* short file names */
10667
10668     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
10669     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10670
10671     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
10672
10673     hpkg = package_from_db(hdb);
10674     ok(hpkg, "failed to create package\n");
10675
10676     MsiCloseHandle(hdb);
10677
10678     CreateDirectoryA("one", NULL);
10679     CreateDirectoryA("four", NULL);
10680
10681     r = MsiDoAction(hpkg, "CostInitialize");
10682     ok(r == ERROR_SUCCESS, "file cost failed\n");
10683
10684     CreateDirectory("five", NULL);
10685     CreateDirectory("eight", NULL);
10686
10687     r = MsiDoAction(hpkg, "FileCost");
10688     ok(r == ERROR_SUCCESS, "file cost failed\n");
10689
10690     CreateDirectory("nine", NULL);
10691     CreateDirectory("twelve", NULL);
10692
10693     r = MsiDoAction(hpkg, "CostFinalize");
10694     ok(r == ERROR_SUCCESS, "file cost failed\n");
10695
10696     lstrcpyA(subsrc, cwd);
10697     lstrcatA(subsrc, "short");
10698     lstrcatA(subsrc, "\\");
10699
10700     /* neither short nor long source directories exist */
10701     size = MAX_PATH;
10702     lstrcpyA(path, "kiwi");
10703     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10704     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10705     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10706     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10707
10708     CreateDirectoryA("short", NULL);
10709
10710     /* short source directory exists */
10711     size = MAX_PATH;
10712     lstrcpyA(path, "kiwi");
10713     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10715     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10716     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10717
10718     CreateDirectoryA("long", NULL);
10719
10720     /* both short and long source directories exist */
10721     size = MAX_PATH;
10722     lstrcpyA(path, "kiwi");
10723     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10724     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10725     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10726     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10727
10728     lstrcpyA(subsrc, cwd);
10729     lstrcatA(subsrc, "one");
10730     lstrcatA(subsrc, "\\");
10731
10732     /* short dir exists before CostInitialize */
10733     size = MAX_PATH;
10734     lstrcpyA(path, "kiwi");
10735     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10736     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10737     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10738     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10739
10740     lstrcpyA(subsrc, cwd);
10741     lstrcatA(subsrc, "three");
10742     lstrcatA(subsrc, "\\");
10743
10744     /* long dir exists before CostInitialize */
10745     size = MAX_PATH;
10746     lstrcpyA(path, "kiwi");
10747     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
10748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10749     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10750     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10751
10752     lstrcpyA(subsrc, cwd);
10753     lstrcatA(subsrc, "five");
10754     lstrcatA(subsrc, "\\");
10755
10756     /* short dir exists before FileCost */
10757     size = MAX_PATH;
10758     lstrcpyA(path, "kiwi");
10759     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
10760     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10761     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10762     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10763
10764     lstrcpyA(subsrc, cwd);
10765     lstrcatA(subsrc, "seven");
10766     lstrcatA(subsrc, "\\");
10767
10768     /* long dir exists before FileCost */
10769     size = MAX_PATH;
10770     lstrcpyA(path, "kiwi");
10771     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
10772     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10773     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10774     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10775
10776     lstrcpyA(subsrc, cwd);
10777     lstrcatA(subsrc, "nine");
10778     lstrcatA(subsrc, "\\");
10779
10780     /* short dir exists before CostFinalize */
10781     size = MAX_PATH;
10782     lstrcpyA(path, "kiwi");
10783     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
10784     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10785     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10786     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10787
10788     lstrcpyA(subsrc, cwd);
10789     lstrcatA(subsrc, "eleven");
10790     lstrcatA(subsrc, "\\");
10791
10792     /* long dir exists before CostFinalize */
10793     size = MAX_PATH;
10794     lstrcpyA(path, "kiwi");
10795     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
10796     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10797     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10798     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10799
10800     MsiCloseHandle(hpkg);
10801     RemoveDirectoryA("short");
10802     RemoveDirectoryA("long");
10803     RemoveDirectoryA("one");
10804     RemoveDirectoryA("four");
10805     RemoveDirectoryA("five");
10806     RemoveDirectoryA("eight");
10807     RemoveDirectoryA("nine");
10808     RemoveDirectoryA("twelve");
10809     DeleteFileA(msifile);
10810 }
10811
10812 static void test_sourcedir(void)
10813 {
10814     MSIHANDLE hdb, hpkg;
10815     CHAR package[10];
10816     CHAR path[MAX_PATH];
10817     CHAR cwd[MAX_PATH];
10818     CHAR subsrc[MAX_PATH];
10819     DWORD size;
10820     UINT r;
10821
10822     lstrcpyA(cwd, CURR_DIR);
10823     lstrcatA(cwd, "\\");
10824
10825     lstrcpyA(subsrc, cwd);
10826     lstrcatA(subsrc, "long");
10827     lstrcatA(subsrc, "\\");
10828
10829     hdb = create_package_db();
10830     ok( hdb, "failed to create database\n");
10831
10832     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10833     ok(r == S_OK, "failed\n");
10834
10835     sprintf(package, "#%i", hdb);
10836     r = MsiOpenPackage(package, &hpkg);
10837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10838
10839     /* properties only */
10840
10841     /* SourceDir prop */
10842     size = MAX_PATH;
10843     lstrcpyA(path, "kiwi");
10844     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10845     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10846     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10847     ok(size == 0, "Expected 0, got %d\n", size);
10848
10849     /* SOURCEDIR prop */
10850     size = MAX_PATH;
10851     lstrcpyA(path, "kiwi");
10852     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10853     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10854     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10855     ok(size == 0, "Expected 0, got %d\n", size);
10856
10857     r = MsiDoAction(hpkg, "CostInitialize");
10858     ok(r == ERROR_SUCCESS, "file cost failed\n");
10859
10860     /* SourceDir after CostInitialize */
10861     size = MAX_PATH;
10862     lstrcpyA(path, "kiwi");
10863     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10865     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10866     ok(size == 0, "Expected 0, got %d\n", size);
10867
10868     /* SOURCEDIR after CostInitialize */
10869     size = MAX_PATH;
10870     lstrcpyA(path, "kiwi");
10871     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10872     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10873     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10874     ok(size == 0, "Expected 0, got %d\n", size);
10875
10876     r = MsiDoAction(hpkg, "FileCost");
10877     ok(r == ERROR_SUCCESS, "file cost failed\n");
10878
10879     /* SourceDir after FileCost */
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     /* SOURCEDIR after FileCost */
10888     size = MAX_PATH;
10889     lstrcpyA(path, "kiwi");
10890     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10892     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10893     ok(size == 0, "Expected 0, got %d\n", size);
10894
10895     r = MsiDoAction(hpkg, "CostFinalize");
10896     ok(r == ERROR_SUCCESS, "file cost failed\n");
10897
10898     /* SourceDir after CostFinalize */
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     /* SOURCEDIR after CostFinalize */
10907     size = MAX_PATH;
10908     lstrcpyA(path, "kiwi");
10909     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10910     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10911     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10912     ok(size == 0, "Expected 0, got %d\n", size);
10913
10914     r = MsiDoAction(hpkg, "ResolveSource");
10915     ok(r == ERROR_SUCCESS, "file cost failed\n");
10916
10917     /* SourceDir after ResolveSource */
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, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10923     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10924
10925     /* SOURCEDIR after ResolveSource */
10926     size = MAX_PATH;
10927     lstrcpyA(path, "kiwi");
10928     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10930     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10931     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10932
10933     /* random casing */
10934     size = MAX_PATH;
10935     lstrcpyA(path, "kiwi");
10936     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
10937     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10938     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10939     ok(size == 0, "Expected 0, got %d\n", size);
10940
10941     MsiCloseHandle(hpkg);
10942
10943     /* reset the package state */
10944     sprintf(package, "#%i", hdb);
10945     r = MsiOpenPackage(package, &hpkg);
10946     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10947
10948     /* test how MsiGetSourcePath affects the properties */
10949
10950     /* SourceDir prop */
10951     size = MAX_PATH;
10952     lstrcpyA(path, "kiwi");
10953     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10954     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10955     todo_wine
10956     {
10957         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10958         ok(size == 0, "Expected 0, got %d\n", size);
10959     }
10960
10961     size = MAX_PATH;
10962     lstrcpyA(path, "kiwi");
10963     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10964     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10965     ok(!lstrcmpA(path, "kiwi"),
10966        "Expected path to be unchanged, got \"%s\"\n", path);
10967     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10968
10969     /* SourceDir after MsiGetSourcePath */
10970     size = MAX_PATH;
10971     lstrcpyA(path, "kiwi");
10972     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10974     todo_wine
10975     {
10976         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10977         ok(size == 0, "Expected 0, got %d\n", size);
10978     }
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 prop 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     r = MsiDoAction(hpkg, "CostInitialize");
11011     ok(r == ERROR_SUCCESS, "file cost failed\n");
11012
11013     /* SourceDir after CostInitialize */
11014     size = MAX_PATH;
11015     lstrcpyA(path, "kiwi");
11016     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11017     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11018     todo_wine
11019     {
11020         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11021         ok(size == 0, "Expected 0, got %d\n", size);
11022     }
11023
11024     size = MAX_PATH;
11025     lstrcpyA(path, "kiwi");
11026     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11027     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11028     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11029     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11030
11031     /* SourceDir after MsiGetSourcePath */
11032     size = MAX_PATH;
11033     lstrcpyA(path, "kiwi");
11034     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11036     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11037     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11038
11039     /* SOURCEDIR after CostInitialize */
11040     size = MAX_PATH;
11041     lstrcpyA(path, "kiwi");
11042     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11043     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11044     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11045     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11046
11047     /* SOURCEDIR source path still does not exist */
11048     size = MAX_PATH;
11049     lstrcpyA(path, "kiwi");
11050     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11051     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11052     ok(!lstrcmpA(path, "kiwi"),
11053        "Expected path to be unchanged, got \"%s\"\n", path);
11054     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11055
11056     r = MsiDoAction(hpkg, "FileCost");
11057     ok(r == ERROR_SUCCESS, "file cost failed\n");
11058
11059     /* SourceDir after FileCost */
11060     size = MAX_PATH;
11061     lstrcpyA(path, "kiwi");
11062     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11063     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11064     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11065     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11066
11067     /* SOURCEDIR after FileCost */
11068     size = MAX_PATH;
11069     lstrcpyA(path, "kiwi");
11070     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11071     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11072     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11073     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11074
11075     /* SOURCEDIR source path still does not exist */
11076     size = MAX_PATH;
11077     lstrcpyA(path, "kiwi");
11078     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11079     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11080     ok(!lstrcmpA(path, "kiwi"),
11081        "Expected path to be unchanged, got \"%s\"\n", path);
11082     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11083
11084     r = MsiDoAction(hpkg, "CostFinalize");
11085     ok(r == ERROR_SUCCESS, "file cost failed\n");
11086
11087     /* SourceDir after CostFinalize */
11088     size = MAX_PATH;
11089     lstrcpyA(path, "kiwi");
11090     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11091     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11092     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11093     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11094
11095     /* SOURCEDIR after CostFinalize */
11096     size = MAX_PATH;
11097     lstrcpyA(path, "kiwi");
11098     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11100     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11101     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11102
11103     /* SOURCEDIR source path still does not exist */
11104     size = MAX_PATH;
11105     lstrcpyA(path, "kiwi");
11106     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11107     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11108     ok(!lstrcmpA(path, "kiwi"),
11109        "Expected path to be unchanged, got \"%s\"\n", path);
11110     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11111
11112     r = MsiDoAction(hpkg, "ResolveSource");
11113     ok(r == ERROR_SUCCESS, "file cost failed\n");
11114
11115     /* SourceDir after ResolveSource */
11116     size = MAX_PATH;
11117     lstrcpyA(path, "kiwi");
11118     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11120     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11121     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11122
11123     /* SOURCEDIR after ResolveSource */
11124     size = MAX_PATH;
11125     lstrcpyA(path, "kiwi");
11126     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11127     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11128     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11129     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11130
11131     /* SOURCEDIR source path still does not exist */
11132     size = MAX_PATH;
11133     lstrcpyA(path, "kiwi");
11134     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11135     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11136     ok(!lstrcmpA(path, "kiwi"),
11137        "Expected path to be unchanged, got \"%s\"\n", path);
11138     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11139
11140     MsiCloseHandle(hdb);
11141     MsiCloseHandle(hpkg);
11142     DeleteFileA(msifile);
11143 }
11144
11145 struct access_res
11146 {
11147     BOOL gothandle;
11148     DWORD lasterr;
11149     BOOL ignore;
11150 };
11151
11152 static const struct access_res create[16] =
11153 {
11154     { TRUE, ERROR_SUCCESS, TRUE },
11155     { TRUE, ERROR_SUCCESS, TRUE },
11156     { TRUE, ERROR_SUCCESS, FALSE },
11157     { TRUE, ERROR_SUCCESS, FALSE },
11158     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11159     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11160     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11161     { TRUE, ERROR_SUCCESS, FALSE },
11162     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11163     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11164     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11165     { TRUE, ERROR_SUCCESS, TRUE },
11166     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11167     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11168     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11169     { TRUE, ERROR_SUCCESS, TRUE }
11170 };
11171
11172 static const struct access_res create_commit[16] =
11173 {
11174     { TRUE, ERROR_SUCCESS, TRUE },
11175     { TRUE, ERROR_SUCCESS, TRUE },
11176     { TRUE, ERROR_SUCCESS, FALSE },
11177     { TRUE, ERROR_SUCCESS, FALSE },
11178     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11179     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11180     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11181     { TRUE, ERROR_SUCCESS, FALSE },
11182     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11183     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11184     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11185     { TRUE, ERROR_SUCCESS, TRUE },
11186     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11187     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11188     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11189     { TRUE, ERROR_SUCCESS, TRUE }
11190 };
11191
11192 static const struct access_res create_close[16] =
11193 {
11194     { TRUE, ERROR_SUCCESS, FALSE },
11195     { TRUE, ERROR_SUCCESS, FALSE },
11196     { TRUE, ERROR_SUCCESS, FALSE },
11197     { TRUE, ERROR_SUCCESS, FALSE },
11198     { TRUE, ERROR_SUCCESS, FALSE },
11199     { TRUE, ERROR_SUCCESS, FALSE },
11200     { TRUE, ERROR_SUCCESS, FALSE },
11201     { TRUE, ERROR_SUCCESS, FALSE },
11202     { TRUE, ERROR_SUCCESS, FALSE },
11203     { TRUE, ERROR_SUCCESS, FALSE },
11204     { TRUE, ERROR_SUCCESS, FALSE },
11205     { TRUE, ERROR_SUCCESS, FALSE },
11206     { TRUE, ERROR_SUCCESS, FALSE },
11207     { TRUE, ERROR_SUCCESS, FALSE },
11208     { TRUE, ERROR_SUCCESS, FALSE },
11209     { TRUE, ERROR_SUCCESS }
11210 };
11211
11212 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
11213 {
11214     DWORD access = 0, share = 0;
11215     DWORD lasterr;
11216     HANDLE hfile;
11217     int i, j, idx = 0;
11218
11219     for (i = 0; i < 4; i++)
11220     {
11221         if (i == 0) access = 0;
11222         if (i == 1) access = GENERIC_READ;
11223         if (i == 2) access = GENERIC_WRITE;
11224         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
11225
11226         for (j = 0; j < 4; j++)
11227         {
11228             if (ares[idx].ignore)
11229                 continue;
11230
11231             if (j == 0) share = 0;
11232             if (j == 1) share = FILE_SHARE_READ;
11233             if (j == 2) share = FILE_SHARE_WRITE;
11234             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
11235
11236             SetLastError(0xdeadbeef);
11237             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
11238                                 FILE_ATTRIBUTE_NORMAL, 0);
11239             lasterr = GetLastError();
11240
11241             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
11242                "(%d, handle, %d): Expected %d, got %d\n",
11243                line, idx, ares[idx].gothandle,
11244                (hfile != INVALID_HANDLE_VALUE));
11245
11246             ok(lasterr == ares[idx].lasterr ||
11247                lasterr == 0xdeadbeef, /* win9x */
11248                "(%d, lasterr, %d): Expected %d, got %d\n",
11249                line, idx, ares[idx].lasterr, lasterr);
11250
11251             CloseHandle(hfile);
11252             idx++;
11253         }
11254     }
11255 }
11256
11257 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
11258
11259 static void test_access(void)
11260 {
11261     MSIHANDLE hdb;
11262     UINT r;
11263
11264     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
11265     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11266
11267     test_file_access(msifile, create);
11268
11269     r = MsiDatabaseCommit(hdb);
11270     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11271
11272     test_file_access(msifile, create_commit);
11273
11274     MsiCloseHandle(hdb);
11275
11276     test_file_access(msifile, create_close);
11277
11278     DeleteFileA(msifile);
11279
11280     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
11281     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11282
11283     test_file_access(msifile, create);
11284
11285     r = MsiDatabaseCommit(hdb);
11286     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11287
11288     test_file_access(msifile, create_commit);
11289
11290     MsiCloseHandle(hdb);
11291
11292     test_file_access(msifile, create_close);
11293
11294     DeleteFileA(msifile);
11295 }
11296
11297 static void test_emptypackage(void)
11298 {
11299     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
11300     MSIHANDLE hview = 0, hrec = 0;
11301     MSICONDITION condition;
11302     CHAR buffer[MAX_PATH];
11303     DWORD size;
11304     UINT r;
11305
11306     r = MsiOpenPackageA("", &hpkg);
11307     todo_wine
11308     {
11309         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11310     }
11311
11312     hdb = MsiGetActiveDatabase(hpkg);
11313     todo_wine
11314     {
11315         ok(hdb != 0, "Expected a valid database handle\n");
11316     }
11317
11318     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
11319     todo_wine
11320     {
11321         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11322     }
11323     r = MsiViewExecute(hview, 0);
11324     todo_wine
11325     {
11326         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11327     }
11328
11329     r = MsiViewFetch(hview, &hrec);
11330     todo_wine
11331     {
11332         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11333     }
11334
11335     size = MAX_PATH;
11336     r = MsiRecordGetString(hrec, 1, buffer, &size);
11337     todo_wine
11338     {
11339         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11340         ok(!lstrcmpA(buffer, "_Property"),
11341            "Expected \"_Property\", got \"%s\"\n", buffer);
11342     }
11343
11344     MsiCloseHandle(hrec);
11345
11346     r = MsiViewFetch(hview, &hrec);
11347     todo_wine
11348     {
11349         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11350     }
11351
11352     size = MAX_PATH;
11353     r = MsiRecordGetString(hrec, 1, buffer, &size);
11354     todo_wine
11355     {
11356         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11357         ok(!lstrcmpA(buffer, "#_FolderCache"),
11358            "Expected \"_Property\", got \"%s\"\n", buffer);
11359     }
11360
11361     MsiCloseHandle(hrec);
11362     MsiViewClose(hview);
11363     MsiCloseHandle(hview);
11364
11365     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
11366     todo_wine
11367     {
11368         ok(condition == MSICONDITION_FALSE,
11369            "Expected MSICONDITION_FALSE, got %d\n", condition);
11370     }
11371
11372     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
11373     todo_wine
11374     {
11375         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11376     }
11377     r = MsiViewExecute(hview, 0);
11378     todo_wine
11379     {
11380         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11381     }
11382
11383     /* _Property table is not empty */
11384     r = MsiViewFetch(hview, &hrec);
11385     todo_wine
11386     {
11387         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11388     }
11389
11390     MsiCloseHandle(hrec);
11391     MsiViewClose(hview);
11392     MsiCloseHandle(hview);
11393
11394     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
11395     todo_wine
11396     {
11397         ok(condition == MSICONDITION_FALSE,
11398            "Expected MSICONDITION_FALSE, got %d\n", condition);
11399     }
11400
11401     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
11402     todo_wine
11403     {
11404         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11405     }
11406     r = MsiViewExecute(hview, 0);
11407     todo_wine
11408     {
11409         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11410     }
11411
11412     /* #_FolderCache is not empty */
11413     r = MsiViewFetch(hview, &hrec);
11414     todo_wine
11415     {
11416         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11417     }
11418
11419     MsiCloseHandle(hrec);
11420     MsiViewClose(hview);
11421     MsiCloseHandle(hview);
11422
11423     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
11424     todo_wine
11425     {
11426         ok(r == ERROR_BAD_QUERY_SYNTAX,
11427            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11428     }
11429
11430     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
11431     todo_wine
11432     {
11433         ok(r == ERROR_BAD_QUERY_SYNTAX,
11434            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11435     }
11436
11437     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
11438     todo_wine
11439     {
11440         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
11441            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
11442     }
11443
11444     MsiCloseHandle(hsuminfo);
11445
11446     r = MsiDatabaseCommit(hdb);
11447     todo_wine
11448     {
11449         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11450     }
11451
11452     MsiCloseHandle(hdb);
11453     MsiCloseHandle(hpkg);
11454 }
11455
11456 static void test_MsiGetProductProperty(void)
11457 {
11458     MSIHANDLE hprod, hdb;
11459     CHAR val[MAX_PATH];
11460     CHAR path[MAX_PATH];
11461     CHAR query[MAX_PATH];
11462     CHAR keypath[MAX_PATH*2];
11463     CHAR prodcode[MAX_PATH];
11464     CHAR prod_squashed[MAX_PATH];
11465     HKEY prodkey, userkey, props;
11466     DWORD size;
11467     LONG res;
11468     UINT r;
11469     SC_HANDLE scm;
11470
11471     scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
11472     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
11473     {
11474         win_skip("Different registry keys on Win9x and WinMe\n");
11475         return;
11476     }
11477     CloseServiceHandle(scm);
11478
11479     GetCurrentDirectoryA(MAX_PATH, path);
11480     lstrcatA(path, "\\");
11481
11482     create_test_guid(prodcode, prod_squashed);
11483
11484     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
11485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11486
11487     r = MsiDatabaseCommit(hdb);
11488     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11489
11490     r = set_summary_info(hdb);
11491     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11492
11493     r = run_query(hdb,
11494             "CREATE TABLE `Directory` ( "
11495             "`Directory` CHAR(255) NOT NULL, "
11496             "`Directory_Parent` CHAR(255), "
11497             "`DefaultDir` CHAR(255) NOT NULL "
11498             "PRIMARY KEY `Directory`)");
11499     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11500
11501     r = run_query(hdb,
11502             "CREATE TABLE `Property` ( "
11503             "`Property` CHAR(72) NOT NULL, "
11504             "`Value` CHAR(255) "
11505             "PRIMARY KEY `Property`)");
11506     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11507
11508     sprintf(query, "INSERT INTO `Property` "
11509             "(`Property`, `Value`) "
11510             "VALUES( 'ProductCode', '%s' )", prodcode);
11511     r = run_query(hdb, query);
11512     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11513
11514     r = MsiDatabaseCommit(hdb);
11515     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11516
11517     MsiCloseHandle(hdb);
11518
11519     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
11520     lstrcatA(keypath, prod_squashed);
11521
11522     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
11523     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11524
11525     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11526     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
11527     lstrcatA(keypath, prod_squashed);
11528
11529     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
11530     if (res == ERROR_ACCESS_DENIED)
11531     {
11532         skip("Not enough rights to perform tests\n");
11533         RegDeleteKeyA(prodkey, "");
11534         RegCloseKey(prodkey);
11535         return;
11536     }
11537     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11538
11539     res = RegCreateKeyA(userkey, "InstallProperties", &props);
11540     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11541
11542     lstrcpyA(val, path);
11543     lstrcatA(val, "\\winetest.msi");
11544     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
11545                          (const BYTE *)val, lstrlenA(val) + 1);
11546     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11547
11548     hprod = 0xdeadbeef;
11549     r = MsiOpenProductA(prodcode, &hprod);
11550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11551     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
11552
11553     /* hProduct is invalid */
11554     size = MAX_PATH;
11555     lstrcpyA(val, "apple");
11556     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
11557     ok(r == ERROR_INVALID_HANDLE,
11558        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11559     ok(!lstrcmpA(val, "apple"),
11560        "Expected val to be unchanged, got \"%s\"\n", val);
11561     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11562
11563     /* szProperty is NULL */
11564     size = MAX_PATH;
11565     lstrcpyA(val, "apple");
11566     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
11567     ok(r == ERROR_INVALID_PARAMETER,
11568        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11569     ok(!lstrcmpA(val, "apple"),
11570        "Expected val to be unchanged, got \"%s\"\n", val);
11571     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11572
11573     /* szProperty is empty */
11574     size = MAX_PATH;
11575     lstrcpyA(val, "apple");
11576     r = MsiGetProductPropertyA(hprod, "", val, &size);
11577     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11578     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11579     ok(size == 0, "Expected 0, got %d\n", size);
11580
11581     /* get the property */
11582     size = MAX_PATH;
11583     lstrcpyA(val, "apple");
11584     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11585     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11586     ok(!lstrcmpA(val, prodcode),
11587        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11588     ok(size == lstrlenA(prodcode),
11589        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11590
11591     /* lpValueBuf is NULL */
11592     size = MAX_PATH;
11593     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
11594     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11595     ok(size == lstrlenA(prodcode),
11596        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11597
11598     /* pcchValueBuf is NULL */
11599     lstrcpyA(val, "apple");
11600     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
11601     ok(r == ERROR_INVALID_PARAMETER,
11602        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11603     ok(!lstrcmpA(val, "apple"),
11604        "Expected val to be unchanged, got \"%s\"\n", val);
11605     ok(size == lstrlenA(prodcode),
11606        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11607
11608     /* pcchValueBuf is too small */
11609     size = 4;
11610     lstrcpyA(val, "apple");
11611     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11612     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11613     ok(!strncmp(val, prodcode, 3),
11614        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
11615     ok(size == lstrlenA(prodcode),
11616        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11617
11618     /* pcchValueBuf does not leave room for NULL terminator */
11619     size = lstrlenA(prodcode);
11620     lstrcpyA(val, "apple");
11621     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11622     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11623     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
11624        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
11625     ok(size == lstrlenA(prodcode),
11626        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11627
11628     /* pcchValueBuf has enough room for NULL terminator */
11629     size = lstrlenA(prodcode) + 1;
11630     lstrcpyA(val, "apple");
11631     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11632     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11633     ok(!lstrcmpA(val, prodcode),
11634        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11635     ok(size == lstrlenA(prodcode),
11636        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11637
11638     /* nonexistent property */
11639     size = MAX_PATH;
11640     lstrcpyA(val, "apple");
11641     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
11642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11643     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11644     ok(size == 0, "Expected 0, got %d\n", size);
11645
11646     r = MsiSetPropertyA(hprod, "NewProperty", "value");
11647     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11648
11649     /* non-product property set */
11650     size = MAX_PATH;
11651     lstrcpyA(val, "apple");
11652     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
11653     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11654     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11655     ok(size == 0, "Expected 0, got %d\n", size);
11656
11657     r = MsiSetPropertyA(hprod, "ProductCode", "value");
11658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11659
11660     /* non-product property that is also a product property set */
11661     size = MAX_PATH;
11662     lstrcpyA(val, "apple");
11663     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11665     ok(!lstrcmpA(val, prodcode),
11666        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11667     ok(size == lstrlenA(prodcode),
11668        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11669
11670     MsiCloseHandle(hprod);
11671
11672     RegDeleteValueA(props, "LocalPackage");
11673     RegDeleteKeyA(props, "");
11674     RegCloseKey(props);
11675     RegDeleteKeyA(userkey, "");
11676     RegCloseKey(userkey);
11677     RegDeleteKeyA(prodkey, "");
11678     RegCloseKey(prodkey);
11679     DeleteFileA(msifile);
11680 }
11681
11682 static void test_MsiSetProperty(void)
11683 {
11684     MSIHANDLE hpkg, hdb, hrec;
11685     CHAR buf[MAX_PATH];
11686     LPCSTR query;
11687     DWORD size;
11688     UINT r;
11689
11690     hpkg = package_from_db(create_package_db());
11691     ok(hpkg != 0, "Expected a valid package\n");
11692
11693     /* invalid hInstall */
11694     r = MsiSetPropertyA(0, "Prop", "Val");
11695     ok(r == ERROR_INVALID_HANDLE,
11696        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11697
11698     /* invalid hInstall */
11699     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
11700     ok(r == ERROR_INVALID_HANDLE,
11701        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11702
11703     /* szName is NULL */
11704     r = MsiSetPropertyA(hpkg, NULL, "Val");
11705     ok(r == ERROR_INVALID_PARAMETER,
11706        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11707
11708     /* both szName and szValue are NULL */
11709     r = MsiSetPropertyA(hpkg, NULL, NULL);
11710     ok(r == ERROR_INVALID_PARAMETER,
11711        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11712
11713     /* szName is empty */
11714     r = MsiSetPropertyA(hpkg, "", "Val");
11715     ok(r == ERROR_FUNCTION_FAILED,
11716        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
11717
11718     /* szName is empty and szValue is NULL */
11719     r = MsiSetPropertyA(hpkg, "", NULL);
11720     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11721
11722     /* set a property */
11723     r = MsiSetPropertyA(hpkg, "Prop", "Val");
11724     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11725
11726     /* get the property */
11727     size = MAX_PATH;
11728     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11729     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11730     ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
11731     ok(size == 3, "Expected 3, got %d\n", size);
11732
11733     /* update the property */
11734     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
11735     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11736
11737     /* get the property */
11738     size = MAX_PATH;
11739     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11740     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11741     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
11742     ok(size == 4, "Expected 4, got %d\n", size);
11743
11744     hdb = MsiGetActiveDatabase(hpkg);
11745     ok(hdb != 0, "Expected a valid database handle\n");
11746
11747     /* set prop is not in the _Property table */
11748     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
11749     r = do_query(hdb, query, &hrec);
11750     ok(r == ERROR_BAD_QUERY_SYNTAX,
11751        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11752
11753     /* set prop is not in the Property table */
11754     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
11755     r = do_query(hdb, query, &hrec);
11756     ok(r == ERROR_BAD_QUERY_SYNTAX,
11757        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11758
11759     MsiCloseHandle(hdb);
11760
11761     /* szValue is an empty string */
11762     r = MsiSetPropertyA(hpkg, "Prop", "");
11763     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11764
11765     /* try to get the property */
11766     size = MAX_PATH;
11767     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11768     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11769     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
11770     ok(size == 0, "Expected 0, got %d\n", size);
11771
11772     /* reset the property */
11773     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
11774     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11775
11776     /* delete the property */
11777     r = MsiSetPropertyA(hpkg, "Prop", NULL);
11778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11779
11780     /* try to get the property */
11781     size = MAX_PATH;
11782     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
11783     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11784     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
11785     ok(size == 0, "Expected 0, got %d\n", size);
11786
11787     MsiCloseHandle(hpkg);
11788     DeleteFileA(msifile);
11789 }
11790
11791 static void test_MsiApplyMultiplePatches(void)
11792 {
11793     UINT r, type = GetDriveType(NULL);
11794
11795     if (!pMsiApplyMultiplePatchesA) {
11796         win_skip("MsiApplyMultiplePatchesA not found\n");
11797         return;
11798     }
11799
11800     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
11801     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11802
11803     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
11804     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11805
11806     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
11807     todo_wine
11808     {
11809         if (type == DRIVE_FIXED)
11810             ok(r == ERROR_PATH_NOT_FOUND,
11811                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
11812         else
11813             ok(r == ERROR_INVALID_NAME,
11814                "Expected ERROR_INVALID_NAME, got %u\n", r);
11815     }
11816
11817     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
11818     todo_wine
11819     {
11820         if (type == DRIVE_FIXED)
11821             ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED,
11822                "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
11823         else
11824             ok(r == ERROR_INVALID_NAME,
11825                "Expected ERROR_INVALID_NAME, got %u\n", r);
11826     }
11827
11828     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
11829     todo_wine
11830     {
11831         if (type == DRIVE_FIXED)
11832             ok(r == ERROR_PATH_NOT_FOUND,
11833                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
11834         else
11835             ok(r == ERROR_INVALID_NAME,
11836                "Expected ERROR_INVALID_NAME, got %u\n", r);
11837     }
11838
11839     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
11840     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
11841
11842     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
11843     todo_wine
11844     {
11845         if (type == DRIVE_FIXED)
11846             ok(r == ERROR_PATH_NOT_FOUND,
11847                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
11848         else
11849             ok(r == ERROR_INVALID_NAME,
11850                "Expected ERROR_INVALID_NAME, got %u\n", r);
11851     }
11852
11853     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
11854     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
11855
11856     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
11857     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
11858 }
11859
11860 static void test_MsiApplyPatch(void)
11861 {
11862     UINT r;
11863
11864     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
11865     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11866
11867     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
11868     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
11869 }
11870
11871 START_TEST(package)
11872 {
11873     init_functionpointers();
11874
11875     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
11876
11877     test_createpackage();
11878     test_doaction();
11879     test_gettargetpath_bad();
11880     test_settargetpath();
11881     test_props();
11882     test_property_table();
11883     test_condition();
11884     test_msipackage();
11885     test_formatrecord2();
11886     test_states();
11887     test_getproperty();
11888     test_removefiles();
11889     test_appsearch();
11890     test_appsearch_complocator();
11891     test_appsearch_reglocator();
11892     test_appsearch_inilocator();
11893     test_appsearch_drlocator();
11894     test_featureparents();
11895     test_installprops();
11896     test_launchconditions();
11897     test_ccpsearch();
11898     test_complocator();
11899     test_MsiGetSourcePath();
11900     test_shortlongsource();
11901     test_sourcedir();
11902     test_access();
11903     test_emptypackage();
11904     test_MsiGetProductProperty();
11905     test_MsiSetProperty();
11906     test_MsiApplyMultiplePatches();
11907     test_MsiApplyPatch();
11908 }