windowscodecs: Handle TIFF's with RowsPerStrip greater than Height.
[wine] / dlls / msi / tests / package.c
1 /*
2  * tests for Microsoft Installer functionality
3  *
4  * Copyright 2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #define COBJMACROS
23
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29 #include <srrestoreptapi.h>
30
31 #include "wine/test.h"
32
33 static const char msifile[] = "winetest-package.msi";
34 char CURR_DIR[MAX_PATH];
35
36 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
37
38 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
39 static BOOL (WINAPI *pGetTokenInformation)( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );
40 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
41 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
42 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
43 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
44
45 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
46 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
47
48 static void init_functionpointers(void)
49 {
50     HMODULE hmsi = GetModuleHandleA("msi.dll");
51     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
52     HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
53     HMODULE hsrclient;
54
55 #define GET_PROC(mod, func) \
56     p ## func = (void*)GetProcAddress(mod, #func);
57
58     GET_PROC(hmsi, MsiApplyMultiplePatchesA);
59
60     GET_PROC(hadvapi32, ConvertSidToStringSidA);
61     GET_PROC(hadvapi32, GetTokenInformation);
62     GET_PROC(hadvapi32, OpenProcessToken);
63     GET_PROC(hadvapi32, RegDeleteKeyExA)
64     GET_PROC(hadvapi32, RegDeleteKeyExW)
65     GET_PROC(hkernel32, IsWow64Process)
66
67     hsrclient = LoadLibraryA("srclient.dll");
68     GET_PROC(hsrclient, SRRemoveRestorePoint);
69     GET_PROC(hsrclient, SRSetRestorePointA);
70 #undef GET_PROC
71 }
72
73 static BOOL is_process_limited(void)
74 {
75     HANDLE token;
76
77     if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
78
79     if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
80     {
81         BOOL ret;
82         TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
83         DWORD size;
84
85         ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
86         CloseHandle(token);
87         return (ret && type == TokenElevationTypeLimited);
88     }
89     return FALSE;
90 }
91
92 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
93 {
94     if (pRegDeleteKeyExA)
95         return pRegDeleteKeyExA( key, subkey, access, 0 );
96     return RegDeleteKeyA( key, subkey );
97 }
98
99 static LPSTR get_user_sid(LPSTR *usersid)
100 {
101     HANDLE token;
102     BYTE buf[1024];
103     DWORD size;
104     PTOKEN_USER user;
105
106     if (!pConvertSidToStringSidA)
107     {
108         win_skip("ConvertSidToStringSidA is not available\n");
109         return NULL;
110     }
111
112     *usersid = NULL;
113     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
114     size = sizeof(buf);
115     GetTokenInformation(token, TokenUser, buf, size, &size);
116     user = (PTOKEN_USER)buf;
117     pConvertSidToStringSidA(user->User.Sid, usersid);
118     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
119     CloseHandle(token);
120     return *usersid;
121 }
122
123 /* RegDeleteTreeW from dlls/advapi32/registry.c */
124 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
125 {
126     LONG ret;
127     DWORD dwMaxSubkeyLen, dwMaxValueLen;
128     DWORD dwMaxLen, dwSize;
129     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
130     HKEY hSubKey = hKey;
131
132     if(lpszSubKey)
133     {
134         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
135         if (ret) return ret;
136     }
137
138     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
139             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
140     if (ret) goto cleanup;
141
142     dwMaxSubkeyLen++;
143     dwMaxValueLen++;
144     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
145     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
146     {
147         /* Name too big: alloc a buffer for it */
148         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
149         {
150             ret = ERROR_NOT_ENOUGH_MEMORY;
151             goto cleanup;
152         }
153     }
154
155     /* Recursively delete all the subkeys */
156     while (TRUE)
157     {
158         dwSize = dwMaxLen;
159         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
160                           NULL, NULL, NULL)) break;
161
162         ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
163         if (ret) goto cleanup;
164     }
165
166     if (lpszSubKey)
167     {
168         if (pRegDeleteKeyExW)
169             ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
170         else
171             ret = RegDeleteKeyW(hKey, lpszSubKey);
172     }
173     else
174         while (TRUE)
175         {
176             dwSize = dwMaxLen;
177             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
178                   NULL, NULL, NULL, NULL)) break;
179
180             ret = RegDeleteValueW(hKey, lpszName);
181             if (ret) goto cleanup;
182         }
183
184 cleanup:
185     if (lpszName != szNameBuf)
186         HeapFree(GetProcessHeap(), 0, lpszName);
187     if(lpszSubKey)
188         RegCloseKey(hSubKey);
189     return ret;
190 }
191
192 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
193 {
194     DWORD i,n=1;
195     GUID guid;
196
197     if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
198         return FALSE;
199
200     for(i=0; i<8; i++)
201         out[7-i] = in[n++];
202     n++;
203     for(i=0; i<4; i++)
204         out[11-i] = in[n++];
205     n++;
206     for(i=0; i<4; i++)
207         out[15-i] = in[n++];
208     n++;
209     for(i=0; i<2; i++)
210     {
211         out[17+i*2] = in[n++];
212         out[16+i*2] = in[n++];
213     }
214     n++;
215     for( ; i<8; i++)
216     {
217         out[17+i*2] = in[n++];
218         out[16+i*2] = in[n++];
219     }
220     out[32]=0;
221     return TRUE;
222 }
223
224 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
225 {
226     WCHAR guidW[MAX_PATH];
227     WCHAR squashedW[MAX_PATH];
228     GUID guid;
229     HRESULT hr;
230     int size;
231
232     hr = CoCreateGuid(&guid);
233     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
234
235     size = StringFromGUID2(&guid, guidW, MAX_PATH);
236     ok(size == 39, "Expected 39, got %d\n", hr);
237
238     WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
239     squash_guid(guidW, squashedW);
240     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
241 }
242
243 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
244                                LPCSTR guid, LPSTR usersid, BOOL dir)
245 {
246     WCHAR guidW[MAX_PATH];
247     WCHAR squashedW[MAX_PATH];
248     CHAR squashed[MAX_PATH];
249     CHAR comppath[MAX_PATH];
250     CHAR prodpath[MAX_PATH];
251     CHAR path[MAX_PATH];
252     LPCSTR prod = NULL;
253     HKEY hkey;
254     REGSAM access = KEY_ALL_ACCESS;
255     BOOL wow64;
256
257     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
258         access |= KEY_WOW64_64KEY;
259
260     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
261     squash_guid(guidW, squashedW);
262     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
263
264     if (context == MSIINSTALLCONTEXT_MACHINE)
265     {
266         prod = "3D0DAE300FACA1300AD792060BCDAA92";
267         sprintf(comppath,
268                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
269                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
270         lstrcpyA(prodpath,
271                  "SOFTWARE\\Classes\\Installer\\"
272                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
273     }
274     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
275     {
276         prod = "7D2F387510109040002000060BECB6AB";
277         sprintf(comppath,
278                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
279                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
280         sprintf(prodpath,
281                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
282                 "Installer\\%s\\Installer\\Products\\"
283                 "7D2F387510109040002000060BECB6AB", usersid);
284     }
285     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
286     {
287         prod = "7D2F387510109040002000060BECB6AB";
288         sprintf(comppath,
289                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
290                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
291         sprintf(prodpath,
292                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
293                 "Installer\\Managed\\%s\\Installer\\Products\\"
294                 "7D2F387510109040002000060BECB6AB", usersid);
295     }
296
297     RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
298
299     lstrcpyA(path, CURR_DIR);
300     lstrcatA(path, "\\");
301     if (!dir) lstrcatA(path, filename);
302
303     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
304     RegCloseKey(hkey);
305
306     RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
307     RegCloseKey(hkey);
308 }
309
310 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
311 {
312     WCHAR guidW[MAX_PATH];
313     WCHAR squashedW[MAX_PATH];
314     WCHAR substrW[MAX_PATH];
315     CHAR squashed[MAX_PATH];
316     CHAR comppath[MAX_PATH];
317     CHAR prodpath[MAX_PATH];
318     REGSAM access = KEY_ALL_ACCESS;
319     BOOL wow64;
320
321     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
322         access |= KEY_WOW64_64KEY;
323
324     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
325     squash_guid(guidW, squashedW);
326     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
327
328     if (context == MSIINSTALLCONTEXT_MACHINE)
329     {
330         sprintf(comppath,
331                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
332                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
333         lstrcpyA(prodpath,
334                  "SOFTWARE\\Classes\\Installer\\"
335                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
336     }
337     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
338     {
339         sprintf(comppath,
340                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
341                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
342         sprintf(prodpath,
343                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
344                 "Installer\\%s\\Installer\\Products\\"
345                 "7D2F387510109040002000060BECB6AB", usersid);
346     }
347     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
348     {
349         sprintf(comppath,
350                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
351                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
352         sprintf(prodpath,
353                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
354                 "Installer\\Managed\\%s\\Installer\\Products\\"
355                 "7D2F387510109040002000060BECB6AB", usersid);
356     }
357
358     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
359     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
360
361     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
362     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
363 }
364
365 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
366 {
367     MSIHANDLE hview = 0;
368     UINT r, ret;
369
370     /* open a select query */
371     r = MsiDatabaseOpenView(hdb, query, &hview);
372     if (r != ERROR_SUCCESS)
373         return r;
374     r = MsiViewExecute(hview, 0);
375     if (r != ERROR_SUCCESS)
376         return r;
377     ret = MsiViewFetch(hview, phrec);
378     r = MsiViewClose(hview);
379     if (r != ERROR_SUCCESS)
380         return r;
381     r = MsiCloseHandle(hview);
382     if (r != ERROR_SUCCESS)
383         return r;
384     return ret;
385 }
386
387 static UINT run_query( MSIHANDLE hdb, const char *query )
388 {
389     MSIHANDLE hview = 0;
390     UINT r;
391
392     r = MsiDatabaseOpenView(hdb, query, &hview);
393     if( r != ERROR_SUCCESS )
394         return r;
395
396     r = MsiViewExecute(hview, 0);
397     if( r == ERROR_SUCCESS )
398         r = MsiViewClose(hview);
399     MsiCloseHandle(hview);
400     return r;
401 }
402
403 static UINT create_component_table( MSIHANDLE hdb )
404 {
405     return run_query( hdb,
406             "CREATE TABLE `Component` ( "
407             "`Component` CHAR(72) NOT NULL, "
408             "`ComponentId` CHAR(38), "
409             "`Directory_` CHAR(72) NOT NULL, "
410             "`Attributes` SHORT NOT NULL, "
411             "`Condition` CHAR(255), "
412             "`KeyPath` CHAR(72) "
413             "PRIMARY KEY `Component`)" );
414 }
415
416 static UINT create_feature_table( MSIHANDLE hdb )
417 {
418     return run_query( hdb,
419             "CREATE TABLE `Feature` ( "
420             "`Feature` CHAR(38) NOT NULL, "
421             "`Feature_Parent` CHAR(38), "
422             "`Title` CHAR(64), "
423             "`Description` CHAR(255), "
424             "`Display` SHORT NOT NULL, "
425             "`Level` SHORT NOT NULL, "
426             "`Directory_` CHAR(72), "
427             "`Attributes` SHORT NOT NULL "
428             "PRIMARY KEY `Feature`)" );
429 }
430
431 static UINT create_feature_components_table( MSIHANDLE hdb )
432 {
433     return run_query( hdb,
434             "CREATE TABLE `FeatureComponents` ( "
435             "`Feature_` CHAR(38) NOT NULL, "
436             "`Component_` CHAR(72) NOT NULL "
437             "PRIMARY KEY `Feature_`, `Component_` )" );
438 }
439
440 static UINT create_file_table( MSIHANDLE hdb )
441 {
442     return run_query( hdb,
443             "CREATE TABLE `File` ("
444             "`File` CHAR(72) NOT NULL, "
445             "`Component_` CHAR(72) NOT NULL, "
446             "`FileName` CHAR(255) NOT NULL, "
447             "`FileSize` LONG NOT NULL, "
448             "`Version` CHAR(72), "
449             "`Language` CHAR(20), "
450             "`Attributes` SHORT, "
451             "`Sequence` SHORT NOT NULL "
452             "PRIMARY KEY `File`)" );
453 }
454
455 static UINT create_remove_file_table( MSIHANDLE hdb )
456 {
457     return run_query( hdb,
458             "CREATE TABLE `RemoveFile` ("
459             "`FileKey` CHAR(72) NOT NULL, "
460             "`Component_` CHAR(72) NOT NULL, "
461             "`FileName` CHAR(255) LOCALIZABLE, "
462             "`DirProperty` CHAR(72) NOT NULL, "
463             "`InstallMode` SHORT NOT NULL "
464             "PRIMARY KEY `FileKey`)" );
465 }
466
467 static UINT create_appsearch_table( MSIHANDLE hdb )
468 {
469     return run_query( hdb,
470             "CREATE TABLE `AppSearch` ("
471             "`Property` CHAR(72) NOT NULL, "
472             "`Signature_` CHAR(72) NOT NULL "
473             "PRIMARY KEY `Property`, `Signature_`)" );
474 }
475
476 static UINT create_reglocator_table( MSIHANDLE hdb )
477 {
478     return run_query( hdb,
479             "CREATE TABLE `RegLocator` ("
480             "`Signature_` CHAR(72) NOT NULL, "
481             "`Root` SHORT NOT NULL, "
482             "`Key` CHAR(255) NOT NULL, "
483             "`Name` CHAR(255), "
484             "`Type` SHORT "
485             "PRIMARY KEY `Signature_`)" );
486 }
487
488 static UINT create_signature_table( MSIHANDLE hdb )
489 {
490     return run_query( hdb,
491             "CREATE TABLE `Signature` ("
492             "`Signature` CHAR(72) NOT NULL, "
493             "`FileName` CHAR(255) NOT NULL, "
494             "`MinVersion` CHAR(20), "
495             "`MaxVersion` CHAR(20), "
496             "`MinSize` LONG, "
497             "`MaxSize` LONG, "
498             "`MinDate` LONG, "
499             "`MaxDate` LONG, "
500             "`Languages` CHAR(255) "
501             "PRIMARY KEY `Signature`)" );
502 }
503
504 static UINT create_launchcondition_table( MSIHANDLE hdb )
505 {
506     return run_query( hdb,
507             "CREATE TABLE `LaunchCondition` ("
508             "`Condition` CHAR(255) NOT NULL, "
509             "`Description` CHAR(255) NOT NULL "
510             "PRIMARY KEY `Condition`)" );
511 }
512
513 static UINT create_property_table( MSIHANDLE hdb )
514 {
515     return run_query( hdb,
516             "CREATE TABLE `Property` ("
517             "`Property` CHAR(72) NOT NULL, "
518             "`Value` CHAR(0) "
519             "PRIMARY KEY `Property`)" );
520 }
521
522 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
523 {
524     return run_query( hdb,
525             "CREATE TABLE `InstallExecuteSequence` ("
526             "`Action` CHAR(72) NOT NULL, "
527             "`Condition` CHAR(255), "
528             "`Sequence` SHORT "
529             "PRIMARY KEY `Action`)" );
530 }
531
532 static UINT create_media_table( MSIHANDLE hdb )
533 {
534     return run_query( hdb,
535             "CREATE TABLE `Media` ("
536             "`DiskId` SHORT NOT NULL, "
537             "`LastSequence` SHORT NOT NULL, "
538             "`DiskPrompt` CHAR(64), "
539             "`Cabinet` CHAR(255), "
540             "`VolumeLabel` CHAR(32), "
541             "`Source` CHAR(72) "
542             "PRIMARY KEY `DiskId`)" );
543 }
544
545 static UINT create_ccpsearch_table( MSIHANDLE hdb )
546 {
547     return run_query( hdb,
548             "CREATE TABLE `CCPSearch` ("
549             "`Signature_` CHAR(72) NOT NULL "
550             "PRIMARY KEY `Signature_`)" );
551 }
552
553 static UINT create_drlocator_table( MSIHANDLE hdb )
554 {
555     return run_query( hdb,
556             "CREATE TABLE `DrLocator` ("
557             "`Signature_` CHAR(72) NOT NULL, "
558             "`Parent` CHAR(72), "
559             "`Path` CHAR(255), "
560             "`Depth` SHORT "
561             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
562 }
563
564 static UINT create_complocator_table( MSIHANDLE hdb )
565 {
566     return run_query( hdb,
567             "CREATE TABLE `CompLocator` ("
568             "`Signature_` CHAR(72) NOT NULL, "
569             "`ComponentId` CHAR(38) NOT NULL, "
570             "`Type` SHORT "
571             "PRIMARY KEY `Signature_`)" );
572 }
573
574 static UINT create_inilocator_table( MSIHANDLE hdb )
575 {
576     return run_query( hdb,
577             "CREATE TABLE `IniLocator` ("
578             "`Signature_` CHAR(72) NOT NULL, "
579             "`FileName` CHAR(255) NOT NULL, "
580             "`Section` CHAR(96)NOT NULL, "
581             "`Key` CHAR(128)NOT NULL, "
582             "`Field` SHORT, "
583             "`Type` SHORT "
584             "PRIMARY KEY `Signature_`)" );
585 }
586
587 #define make_add_entry(type, qtext) \
588     static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
589     { \
590         char insert[] = qtext; \
591         char *query; \
592         UINT sz, r; \
593         sz = strlen(values) + sizeof insert; \
594         query = HeapAlloc(GetProcessHeap(),0,sz); \
595         sprintf(query,insert,values); \
596         r = run_query( hdb, query ); \
597         HeapFree(GetProcessHeap(), 0, query); \
598         return r; \
599     }
600
601 make_add_entry(component,
602                "INSERT INTO `Component`  "
603                "(`Component`, `ComponentId`, `Directory_`, "
604                "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
605
606 make_add_entry(directory,
607                "INSERT INTO `Directory` "
608                "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
609
610 make_add_entry(feature,
611                "INSERT INTO `Feature` "
612                "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
613                "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
614
615 make_add_entry(feature_components,
616                "INSERT INTO `FeatureComponents` "
617                "(`Feature_`, `Component_`) VALUES( %s )")
618
619 make_add_entry(file,
620                "INSERT INTO `File` "
621                "(`File`, `Component_`, `FileName`, `FileSize`, "
622                "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
623
624 make_add_entry(appsearch,
625                "INSERT INTO `AppSearch` "
626                "(`Property`, `Signature_`) VALUES( %s )")
627
628 make_add_entry(reglocator,
629                "INSERT INTO `RegLocator` "
630                "(`Signature_`, `Root`, `Key`, `Name`, `Type`) VALUES( %s )")
631
632 make_add_entry(signature,
633                "INSERT INTO `Signature` "
634                "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
635                " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
636                "VALUES( %s )")
637
638 make_add_entry(launchcondition,
639                "INSERT INTO `LaunchCondition` "
640                "(`Condition`, `Description`) VALUES( %s )")
641
642 make_add_entry(property,
643                "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
644
645 make_add_entry(install_execute_sequence,
646                "INSERT INTO `InstallExecuteSequence` "
647                "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
648
649 make_add_entry(media,
650                "INSERT INTO `Media` "
651                "(`DiskId`, `LastSequence`, `DiskPrompt`, "
652                "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
653
654 make_add_entry(ccpsearch,
655                "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
656
657 make_add_entry(drlocator,
658                "INSERT INTO `DrLocator` "
659                "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
660
661 make_add_entry(complocator,
662                "INSERT INTO `CompLocator` "
663                "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
664
665 make_add_entry(inilocator,
666                "INSERT INTO `IniLocator` "
667                "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
668                "VALUES( %s )")
669
670 static UINT set_summary_info(MSIHANDLE hdb)
671 {
672     UINT res;
673     MSIHANDLE suminfo;
674
675     /* build summary info */
676     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
677     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
678
679     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
680                         "Installation Database");
681     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
682
683     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
684                         "Installation Database");
685     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
686
687     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
688                         "Wine Hackers");
689     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
690
691     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
692                     ";1033");
693     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
694
695     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
696                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
697     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
698
699     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
700     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
701
702     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
703     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
704
705     res = MsiSummaryInfoPersist(suminfo);
706     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
707
708     res = MsiCloseHandle( suminfo);
709     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
710
711     return res;
712 }
713
714
715 static MSIHANDLE create_package_db(void)
716 {
717     MSIHANDLE hdb = 0;
718     UINT res;
719
720     DeleteFile(msifile);
721
722     /* create an empty database */
723     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
724     ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
725     if( res != ERROR_SUCCESS )
726         return hdb;
727
728     res = MsiDatabaseCommit( hdb );
729     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
730
731     res = set_summary_info(hdb);
732
733     res = run_query( hdb,
734             "CREATE TABLE `Directory` ( "
735             "`Directory` CHAR(255) NOT NULL, "
736             "`Directory_Parent` CHAR(255), "
737             "`DefaultDir` CHAR(255) NOT NULL "
738             "PRIMARY KEY `Directory`)" );
739     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
740
741     return hdb;
742 }
743
744 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
745 {
746     UINT res;
747     CHAR szPackage[12];
748     MSIHANDLE hPackage;
749
750     sprintf(szPackage, "#%u", hdb);
751     res = MsiOpenPackage(szPackage, &hPackage);
752     if (res != ERROR_SUCCESS)
753     {
754         MsiCloseHandle(hdb);
755         return res;
756     }
757
758     res = MsiCloseHandle(hdb);
759     if (res != ERROR_SUCCESS)
760     {
761         MsiCloseHandle(hPackage);
762         return res;
763     }
764
765     *handle = hPackage;
766     return ERROR_SUCCESS;
767 }
768
769 static void create_test_file(const CHAR *name)
770 {
771     HANDLE file;
772     DWORD written;
773
774     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
775     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
776     WriteFile(file, name, strlen(name), &written, NULL);
777     WriteFile(file, "\n", strlen("\n"), &written, NULL);
778     CloseHandle(file);
779 }
780
781 typedef struct _tagVS_VERSIONINFO
782 {
783     WORD wLength;
784     WORD wValueLength;
785     WORD wType;
786     WCHAR szKey[1];
787     WORD wPadding1[1];
788     VS_FIXEDFILEINFO Value;
789     WORD wPadding2[1];
790     WORD wChildren[1];
791 } VS_VERSIONINFO;
792
793 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
794 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
795
796 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
797 {
798     VS_VERSIONINFO *pVerInfo;
799     VS_FIXEDFILEINFO *pFixedInfo;
800     LPBYTE buffer, ofs;
801     CHAR path[MAX_PATH];
802     DWORD handle, size;
803     HANDLE resource;
804     BOOL ret = FALSE;
805
806     GetSystemDirectory(path, MAX_PATH);
807     /* Some dlls can't be updated on Vista/W2K8 */
808     lstrcatA(path, "\\version.dll");
809
810     CopyFileA(path, name, FALSE);
811
812     size = GetFileVersionInfoSize(path, &handle);
813     buffer = HeapAlloc(GetProcessHeap(), 0, size);
814
815     GetFileVersionInfoA(path, 0, size, buffer);
816
817     pVerInfo = (VS_VERSIONINFO *)buffer;
818     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
819     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
820
821     pFixedInfo->dwFileVersionMS = ms;
822     pFixedInfo->dwFileVersionLS = ls;
823     pFixedInfo->dwProductVersionMS = ms;
824     pFixedInfo->dwProductVersionLS = ls;
825
826     resource = BeginUpdateResource(name, FALSE);
827     if (!resource)
828         goto done;
829
830     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
831                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
832         goto done;
833
834     if (!EndUpdateResource(resource, FALSE))
835         goto done;
836
837     ret = TRUE;
838
839 done:
840     HeapFree(GetProcessHeap(), 0, buffer);
841     return ret;
842 }
843
844 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
845 {
846     RESTOREPOINTINFOA spec;
847
848     spec.dwEventType = event_type;
849     spec.dwRestorePtType = APPLICATION_INSTALL;
850     spec.llSequenceNumber = status->llSequenceNumber;
851     lstrcpyA(spec.szDescription, "msitest restore point");
852
853     return pSRSetRestorePointA(&spec, status);
854 }
855
856 static void remove_restore_point(DWORD seq_number)
857 {
858     DWORD res;
859
860     res = pSRRemoveRestorePoint(seq_number);
861     if (res != ERROR_SUCCESS)
862         trace("Failed to remove the restore point : %08x\n", res);
863 }
864
865 static void test_createpackage(void)
866 {
867     MSIHANDLE hPackage = 0;
868     UINT res;
869
870     res = package_from_db(create_package_db(), &hPackage);
871     if (res == ERROR_INSTALL_PACKAGE_REJECTED)
872     {
873         skip("Not enough rights to perform tests\n");
874         DeleteFile(msifile);
875         return;
876     }
877     ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
878
879     res = MsiCloseHandle( hPackage);
880     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
881     DeleteFile(msifile);
882 }
883
884 static void test_doaction( void )
885 {
886     MSIHANDLE hpkg;
887     UINT r;
888
889     r = MsiDoAction( -1, NULL );
890     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
891
892     r = package_from_db(create_package_db(), &hpkg);
893     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
894     {
895         skip("Not enough rights to perform tests\n");
896         DeleteFile(msifile);
897         return;
898     }
899     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
900
901     r = MsiDoAction(hpkg, NULL);
902     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
903
904     r = MsiDoAction(0, "boo");
905     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
906
907     r = MsiDoAction(hpkg, "boo");
908     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
909
910     MsiCloseHandle( hpkg );
911     DeleteFile(msifile);
912 }
913
914 static void test_gettargetpath_bad(void)
915 {
916     static const WCHAR boo[] = {'b','o','o',0};
917     static const WCHAR empty[] = {0};
918     char buffer[0x80];
919     WCHAR bufferW[0x80];
920     MSIHANDLE hpkg;
921     DWORD sz;
922     UINT r;
923
924     r = package_from_db(create_package_db(), &hpkg);
925     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
926     {
927         skip("Not enough rights to perform tests\n");
928         DeleteFile(msifile);
929         return;
930     }
931     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
932
933     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
934     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
935
936     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
937     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
938
939     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
940     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
941
942     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
943     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
944
945     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
946     ok( r == ERROR_DIRECTORY, "wrong return val\n");
947
948     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
949     ok( r == ERROR_DIRECTORY, "wrong return val\n");
950
951     sz = 0;
952     r = MsiGetTargetPath( hpkg, "", buffer, &sz );
953     ok( r == ERROR_DIRECTORY, "wrong return val\n");
954
955     r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
956     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
957
958     r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
959     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
960
961     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
962     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
963
964     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
965     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
966
967     r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
968     ok( r == ERROR_DIRECTORY, "wrong return val\n");
969
970     r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
971     ok( r == ERROR_DIRECTORY, "wrong return val\n");
972
973     sz = 0;
974     r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
975     ok( r == ERROR_DIRECTORY, "wrong return val\n");
976
977     MsiCloseHandle( hpkg );
978     DeleteFile(msifile);
979 }
980
981 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
982 {
983     UINT r;
984     DWORD size;
985     MSIHANDLE rec;
986
987     rec = MsiCreateRecord( 1 );
988     ok(rec, "MsiCreate record failed\n");
989
990     r = MsiRecordSetString( rec, 0, file );
991     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
992
993     size = MAX_PATH;
994     r = MsiFormatRecord( hpkg, rec, buff, &size );
995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
996
997     MsiCloseHandle( rec );
998 }
999
1000 static void test_settargetpath(void)
1001 {
1002     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1003     DWORD sz;
1004     MSIHANDLE hpkg;
1005     UINT r;
1006     MSIHANDLE hdb;
1007
1008     hdb = create_package_db();
1009     ok ( hdb, "failed to create package database\n" );
1010
1011     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1012     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1013
1014     r = create_component_table( hdb );
1015     ok( r == S_OK, "cannot create Component table: %d\n", r );
1016
1017     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1018     ok( r == S_OK, "cannot add dummy component: %d\n", r );
1019
1020     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1021     ok( r == S_OK, "cannot add test component: %d\n", r );
1022
1023     r = create_feature_table( hdb );
1024     ok( r == S_OK, "cannot create Feature table: %d\n", r );
1025
1026     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1027     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1028
1029     r = create_feature_components_table( hdb );
1030     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1031
1032     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1033     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1034
1035     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1036     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1037
1038     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1039     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1040
1041     r = create_file_table( hdb );
1042     ok( r == S_OK, "cannot create File table: %d\n", r );
1043
1044     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1045     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1046
1047     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1048     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1049
1050     r = package_from_db( hdb, &hpkg );
1051     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1052     {
1053         skip("Not enough rights to perform tests\n");
1054         DeleteFile(msifile);
1055         return;
1056     }
1057     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1058
1059     r = MsiDoAction( hpkg, "CostInitialize");
1060     ok( r == ERROR_SUCCESS, "cost init failed\n");
1061
1062     r = MsiDoAction( hpkg, "FileCost");
1063     ok( r == ERROR_SUCCESS, "file cost failed\n");
1064
1065     r = MsiDoAction( hpkg, "CostFinalize");
1066     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1067
1068     r = MsiSetTargetPath( 0, NULL, NULL );
1069     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1070
1071     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1072     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1073
1074     r = MsiSetTargetPath( hpkg, "boo", NULL );
1075     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1076
1077     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1078     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1079
1080     sz = sizeof tempdir - 1;
1081     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1082     sprintf( file, "%srootfile.txt", tempdir );
1083     buffer[0] = 0;
1084     query_file_path( hpkg, "[#RootFile]", buffer );
1085     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1086     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1087
1088     GetTempFileName( tempdir, "_wt", 0, buffer );
1089     sprintf( tempdir, "%s\\subdir", buffer );
1090
1091     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1092     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1093         "MsiSetTargetPath on file returned %d\n", r );
1094
1095     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1096     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1097         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1098
1099     DeleteFile( buffer );
1100
1101     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1102     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1103
1104     r = GetFileAttributes( buffer );
1105     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1106
1107     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1108     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1109
1110     sz = sizeof buffer - 1;
1111     lstrcat( tempdir, "\\" );
1112     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1113     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1114     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1115
1116     sprintf( file, "%srootfile.txt", tempdir );
1117     query_file_path( hpkg, "[#RootFile]", buffer );
1118     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1119
1120     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1121     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1122
1123     query_file_path( hpkg, "[#TestFile]", buffer );
1124     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1125         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1126
1127     sz = sizeof buffer - 1;
1128     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1129     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1130     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1131
1132     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1133     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1134
1135     sz = sizeof buffer - 1;
1136     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1137     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1138     ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1139
1140     MsiCloseHandle( hpkg );
1141 }
1142
1143 static void test_condition(void)
1144 {
1145     MSICONDITION r;
1146     MSIHANDLE hpkg;
1147
1148     r = package_from_db(create_package_db(), &hpkg);
1149     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1150     {
1151         skip("Not enough rights to perform tests\n");
1152         DeleteFile(msifile);
1153         return;
1154     }
1155     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1156
1157     r = MsiEvaluateCondition(0, NULL);
1158     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1159
1160     r = MsiEvaluateCondition(hpkg, NULL);
1161     ok( r == MSICONDITION_NONE, "wrong return val\n");
1162
1163     r = MsiEvaluateCondition(hpkg, "");
1164     ok( r == MSICONDITION_NONE, "wrong return val\n");
1165
1166     r = MsiEvaluateCondition(hpkg, "1");
1167     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1168
1169     r = MsiEvaluateCondition(hpkg, "0");
1170     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1171
1172     r = MsiEvaluateCondition(hpkg, "-1");
1173     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1174
1175     r = MsiEvaluateCondition(hpkg, "0 = 0");
1176     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1177
1178     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1179     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1180
1181     r = MsiEvaluateCondition(hpkg, "0 = 1");
1182     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1183
1184     r = MsiEvaluateCondition(hpkg, "0 > 1");
1185     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1186
1187     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1188     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1189
1190     r = MsiEvaluateCondition(hpkg, "1 > 1");
1191     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1192
1193     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1194     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1195
1196     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1197     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1198
1199     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1200     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1201
1202     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1203     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1204
1205     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1206     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1207
1208     r = MsiEvaluateCondition(hpkg, "0 < 1");
1209     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1210
1211     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1212     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1213
1214     r = MsiEvaluateCondition(hpkg, "1 < 1");
1215     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1216
1217     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1218     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1219
1220     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1221     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1222
1223     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1224     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1225
1226     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1227     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1228
1229     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1230     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1231
1232     r = MsiEvaluateCondition(hpkg, "0 >=");
1233     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1234
1235     r = MsiEvaluateCondition(hpkg, " ");
1236     ok( r == MSICONDITION_NONE, "wrong return val\n");
1237
1238     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1239     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1240
1241     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1242     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1243
1244     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1245     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1246
1247     r = MsiEvaluateCondition(hpkg, "not 0");
1248     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1249
1250     r = MsiEvaluateCondition(hpkg, "not LicView");
1251     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1252
1253     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1254     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1255
1256     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1257     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1258
1259     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1260     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1263     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1266     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, "\"0\"");
1269     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, "1 and 2");
1272     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1275     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1278     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1281     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, "(0)");
1284     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1287     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1290     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1293     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1296     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1299     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1302     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1305     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1308     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1311     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1314     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1317     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1318
1319     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1320     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1321
1322     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1323     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1324
1325     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1326     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1327
1328     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1329     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330
1331     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1332     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1333
1334     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1335     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1336
1337     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1338     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1339
1340     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1341     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1342
1343     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1344     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345
1346     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1347     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1348
1349     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1350     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1351
1352     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1353     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1354
1355     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1356     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1357
1358     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1359     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1360
1361     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1362     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1363
1364     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1365     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1366
1367     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1368     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1369
1370     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1371     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1372
1373     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1374     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1375
1376     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1377     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1378
1379     MsiSetProperty(hpkg, "mm", "5" );
1380
1381     r = MsiEvaluateCondition(hpkg, "mm = 5");
1382     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1383
1384     r = MsiEvaluateCondition(hpkg, "mm < 6");
1385     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1386
1387     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1388     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1389
1390     r = MsiEvaluateCondition(hpkg, "mm > 4");
1391     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1392
1393     r = MsiEvaluateCondition(hpkg, "mm < 12");
1394     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1395
1396     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1397     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1398
1399     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1400     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1401
1402     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1403     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1404
1405     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1406     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1407
1408     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1409     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1410
1411     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1412     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1413
1414     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1415     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1416
1417     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1418     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1419
1420     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1421     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1422
1423     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1424     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1425
1426     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1427     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1430     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1431
1432     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1433     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1434
1435     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1436     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1437
1438     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1439     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1440
1441     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1442     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1443
1444     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1445     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1446
1447     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1448     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1449
1450     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1451     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1452
1453     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1454     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1455
1456     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1457     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1458
1459     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1460     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1461
1462     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1463     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1464
1465     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1466     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1467
1468     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1469     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1470
1471     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1472     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1473
1474     MsiSetProperty(hpkg, "bandalmael", "0" );
1475     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1476     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1477
1478     MsiSetProperty(hpkg, "bandalmael", "" );
1479     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1480     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1481
1482     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1483     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1484     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1485
1486     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1487     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1488     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1489
1490     MsiSetProperty(hpkg, "bandalmael", "0 " );
1491     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1492     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1493
1494     MsiSetProperty(hpkg, "bandalmael", "-0" );
1495     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1496     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1497
1498     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1499     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1500     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1501
1502     MsiSetProperty(hpkg, "bandalmael", "--0" );
1503     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1504     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1505
1506     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1507     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1508     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1509
1510     MsiSetProperty(hpkg, "bandalmael", "-" );
1511     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1512     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1513
1514     MsiSetProperty(hpkg, "bandalmael", "+0" );
1515     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1516     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1517
1518     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1519     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1520     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1521     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1522     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1523
1524     MsiSetProperty(hpkg, "one", "hi");
1525     MsiSetProperty(hpkg, "two", "hithere");
1526     r = MsiEvaluateCondition(hpkg, "one >< two");
1527     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1528
1529     MsiSetProperty(hpkg, "one", "hithere");
1530     MsiSetProperty(hpkg, "two", "hi");
1531     r = MsiEvaluateCondition(hpkg, "one >< two");
1532     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1533
1534     MsiSetProperty(hpkg, "one", "hello");
1535     MsiSetProperty(hpkg, "two", "hi");
1536     r = MsiEvaluateCondition(hpkg, "one >< two");
1537     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1538
1539     MsiSetProperty(hpkg, "one", "hellohithere");
1540     MsiSetProperty(hpkg, "two", "hi");
1541     r = MsiEvaluateCondition(hpkg, "one >< two");
1542     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1543
1544     MsiSetProperty(hpkg, "one", "");
1545     MsiSetProperty(hpkg, "two", "hi");
1546     r = MsiEvaluateCondition(hpkg, "one >< two");
1547     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1548
1549     MsiSetProperty(hpkg, "one", "hi");
1550     MsiSetProperty(hpkg, "two", "");
1551     r = MsiEvaluateCondition(hpkg, "one >< two");
1552     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1553
1554     MsiSetProperty(hpkg, "one", "");
1555     MsiSetProperty(hpkg, "two", "");
1556     r = MsiEvaluateCondition(hpkg, "one >< two");
1557     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1558
1559     MsiSetProperty(hpkg, "one", "1234");
1560     MsiSetProperty(hpkg, "two", "1");
1561     r = MsiEvaluateCondition(hpkg, "one >< two");
1562     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1563
1564     MsiSetProperty(hpkg, "one", "one 1234");
1565     MsiSetProperty(hpkg, "two", "1");
1566     r = MsiEvaluateCondition(hpkg, "one >< two");
1567     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1568
1569     MsiSetProperty(hpkg, "one", "hithere");
1570     MsiSetProperty(hpkg, "two", "hi");
1571     r = MsiEvaluateCondition(hpkg, "one << two");
1572     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1573
1574     MsiSetProperty(hpkg, "one", "hi");
1575     MsiSetProperty(hpkg, "two", "hithere");
1576     r = MsiEvaluateCondition(hpkg, "one << two");
1577     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1578
1579     MsiSetProperty(hpkg, "one", "hi");
1580     MsiSetProperty(hpkg, "two", "hi");
1581     r = MsiEvaluateCondition(hpkg, "one << two");
1582     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1583
1584     MsiSetProperty(hpkg, "one", "abcdhithere");
1585     MsiSetProperty(hpkg, "two", "hi");
1586     r = MsiEvaluateCondition(hpkg, "one << two");
1587     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1588
1589     MsiSetProperty(hpkg, "one", "");
1590     MsiSetProperty(hpkg, "two", "hi");
1591     r = MsiEvaluateCondition(hpkg, "one << two");
1592     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1593
1594     MsiSetProperty(hpkg, "one", "hithere");
1595     MsiSetProperty(hpkg, "two", "");
1596     r = MsiEvaluateCondition(hpkg, "one << two");
1597     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1598
1599     MsiSetProperty(hpkg, "one", "");
1600     MsiSetProperty(hpkg, "two", "");
1601     r = MsiEvaluateCondition(hpkg, "one << two");
1602     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1603
1604     MsiSetProperty(hpkg, "one", "1234");
1605     MsiSetProperty(hpkg, "two", "1");
1606     r = MsiEvaluateCondition(hpkg, "one << two");
1607     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1608
1609     MsiSetProperty(hpkg, "one", "1234 one");
1610     MsiSetProperty(hpkg, "two", "1");
1611     r = MsiEvaluateCondition(hpkg, "one << two");
1612     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1613
1614     MsiSetProperty(hpkg, "one", "hithere");
1615     MsiSetProperty(hpkg, "two", "there");
1616     r = MsiEvaluateCondition(hpkg, "one >> two");
1617     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1618
1619     MsiSetProperty(hpkg, "one", "hithere");
1620     MsiSetProperty(hpkg, "two", "hi");
1621     r = MsiEvaluateCondition(hpkg, "one >> two");
1622     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1623
1624     MsiSetProperty(hpkg, "one", "there");
1625     MsiSetProperty(hpkg, "two", "hithere");
1626     r = MsiEvaluateCondition(hpkg, "one >> two");
1627     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1628
1629     MsiSetProperty(hpkg, "one", "there");
1630     MsiSetProperty(hpkg, "two", "there");
1631     r = MsiEvaluateCondition(hpkg, "one >> two");
1632     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1633
1634     MsiSetProperty(hpkg, "one", "abcdhithere");
1635     MsiSetProperty(hpkg, "two", "hi");
1636     r = MsiEvaluateCondition(hpkg, "one >> two");
1637     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1638
1639     MsiSetProperty(hpkg, "one", "");
1640     MsiSetProperty(hpkg, "two", "there");
1641     r = MsiEvaluateCondition(hpkg, "one >> two");
1642     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1643
1644     MsiSetProperty(hpkg, "one", "there");
1645     MsiSetProperty(hpkg, "two", "");
1646     r = MsiEvaluateCondition(hpkg, "one >> two");
1647     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1648
1649     MsiSetProperty(hpkg, "one", "");
1650     MsiSetProperty(hpkg, "two", "");
1651     r = MsiEvaluateCondition(hpkg, "one >> two");
1652     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1653
1654     MsiSetProperty(hpkg, "one", "1234");
1655     MsiSetProperty(hpkg, "two", "4");
1656     r = MsiEvaluateCondition(hpkg, "one >> two");
1657     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1658
1659     MsiSetProperty(hpkg, "one", "one 1234");
1660     MsiSetProperty(hpkg, "two", "4");
1661     r = MsiEvaluateCondition(hpkg, "one >> two");
1662     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1663
1664     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1665
1666     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1667     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1668
1669     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1670     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1671
1672     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1673     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1674
1675     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1676     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1677
1678     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1679     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1680
1681     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1682     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1683
1684     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1685     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1686
1687     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1688     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1689
1690     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1691     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1692
1693     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1694     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1695
1696     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1697     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1698
1699     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1700     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1701
1702     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1703     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1704
1705     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1706     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1707
1708     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1709     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1710
1711     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1712     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1713
1714     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1715     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1716
1717     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1718     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1719
1720     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1721     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1722
1723     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1724     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1725
1726     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1727     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1728
1729     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1730     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1731
1732     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1733     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1734
1735     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1736     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1737
1738     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1739     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1740
1741     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1742     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1743
1744     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1745     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1746
1747     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1748     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749
1750     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1751     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1752
1753     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1754     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1755
1756     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1757     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1758
1759     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1760     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1761
1762     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1763     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1764
1765     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1766     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1767
1768     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1769     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1770
1771     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1772     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1773
1774     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1775     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1776
1777     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1778     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1779     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1780
1781     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1782     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1783
1784     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1785     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1786
1787     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1788     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1789
1790     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1791     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1792
1793     MsiSetProperty(hpkg, "one", "1");
1794     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1795     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1796
1797     MsiSetProperty(hpkg, "X", "5.0");
1798
1799     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1800     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1801
1802     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1803     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1804
1805     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1806     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1807
1808     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1809     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1810
1811     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1812     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1813
1814     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1815     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1816
1817     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1818     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1819
1820     /* feature doesn't exist */
1821     r = MsiEvaluateCondition(hpkg, "&nofeature");
1822     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1823
1824     MsiSetProperty(hpkg, "A", "2");
1825     MsiSetProperty(hpkg, "X", "50");
1826
1827     r = MsiEvaluateCondition(hpkg, "2 <= X");
1828     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1829
1830     r = MsiEvaluateCondition(hpkg, "A <= X");
1831     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1832
1833     r = MsiEvaluateCondition(hpkg, "A <= 50");
1834     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1835
1836     MsiSetProperty(hpkg, "X", "50val");
1837
1838     r = MsiEvaluateCondition(hpkg, "2 <= X");
1839     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1840
1841     r = MsiEvaluateCondition(hpkg, "A <= X");
1842     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1843
1844     MsiSetProperty(hpkg, "A", "7");
1845     MsiSetProperty(hpkg, "X", "50");
1846
1847     r = MsiEvaluateCondition(hpkg, "7 <= X");
1848     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1849
1850     r = MsiEvaluateCondition(hpkg, "A <= X");
1851     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1852
1853     r = MsiEvaluateCondition(hpkg, "A <= 50");
1854     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1855
1856     MsiSetProperty(hpkg, "X", "50val");
1857
1858     r = MsiEvaluateCondition(hpkg, "2 <= X");
1859     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1860
1861     r = MsiEvaluateCondition(hpkg, "A <= X");
1862     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1863
1864     MsiCloseHandle( hpkg );
1865     DeleteFile(msifile);
1866 }
1867
1868 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1869 {
1870     UINT r;
1871     DWORD sz;
1872     char buffer[2];
1873
1874     sz = sizeof buffer;
1875     strcpy(buffer,"x");
1876     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1877     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1878 }
1879
1880 static void test_props(void)
1881 {
1882     MSIHANDLE hpkg, hdb;
1883     UINT r;
1884     DWORD sz;
1885     char buffer[0x100];
1886
1887     hdb = create_package_db();
1888     r = run_query( hdb,
1889             "CREATE TABLE `Property` ( "
1890             "`Property` CHAR(255) NOT NULL, "
1891             "`Value` CHAR(255) "
1892             "PRIMARY KEY `Property`)" );
1893     ok( r == ERROR_SUCCESS , "Failed\n" );
1894
1895     r = run_query(hdb,
1896             "INSERT INTO `Property` "
1897             "(`Property`, `Value`) "
1898             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1899     ok( r == ERROR_SUCCESS , "Failed\n" );
1900
1901     r = package_from_db( hdb, &hpkg );
1902     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1903     {
1904         skip("Not enough rights to perform tests\n");
1905         DeleteFile(msifile);
1906         return;
1907     }
1908     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1909
1910     /* test invalid values */
1911     r = MsiGetProperty( 0, NULL, NULL, NULL );
1912     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1913
1914     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1915     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1916
1917     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1918     ok( r == ERROR_SUCCESS, "wrong return val\n");
1919
1920     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1921     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1922
1923     /* test retrieving an empty/nonexistent property */
1924     sz = sizeof buffer;
1925     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1926     ok( r == ERROR_SUCCESS, "wrong return val\n");
1927     ok( sz == 0, "wrong size returned\n");
1928
1929     check_prop_empty( hpkg, "boo");
1930     sz = 0;
1931     strcpy(buffer,"x");
1932     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1933     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1934     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1935     ok( sz == 0, "wrong size returned\n");
1936
1937     sz = 1;
1938     strcpy(buffer,"x");
1939     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1940     ok( r == ERROR_SUCCESS, "wrong return val\n");
1941     ok( buffer[0] == 0, "buffer was not changed\n");
1942     ok( sz == 0, "wrong size returned\n");
1943
1944     /* set the property to something */
1945     r = MsiSetProperty( 0, NULL, NULL );
1946     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1947
1948     r = MsiSetProperty( hpkg, NULL, NULL );
1949     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1950
1951     r = MsiSetProperty( hpkg, "", NULL );
1952     ok( r == ERROR_SUCCESS, "wrong return val\n");
1953
1954     /* try set and get some illegal property identifiers */
1955     r = MsiSetProperty( hpkg, "", "asdf" );
1956     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1957
1958     r = MsiSetProperty( hpkg, "=", "asdf" );
1959     ok( r == ERROR_SUCCESS, "wrong return val\n");
1960
1961     r = MsiSetProperty( hpkg, " ", "asdf" );
1962     ok( r == ERROR_SUCCESS, "wrong return val\n");
1963
1964     r = MsiSetProperty( hpkg, "'", "asdf" );
1965     ok( r == ERROR_SUCCESS, "wrong return val\n");
1966
1967     sz = sizeof buffer;
1968     buffer[0]=0;
1969     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1970     ok( r == ERROR_SUCCESS, "wrong return val\n");
1971     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1972
1973     /* set empty values */
1974     r = MsiSetProperty( hpkg, "boo", NULL );
1975     ok( r == ERROR_SUCCESS, "wrong return val\n");
1976     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1977
1978     r = MsiSetProperty( hpkg, "boo", "" );
1979     ok( r == ERROR_SUCCESS, "wrong return val\n");
1980     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1981
1982     /* set a non-empty value */
1983     r = MsiSetProperty( hpkg, "boo", "xyz" );
1984     ok( r == ERROR_SUCCESS, "wrong return val\n");
1985
1986     sz = 1;
1987     strcpy(buffer,"x");
1988     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1989     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1990     ok( buffer[0] == 0, "buffer was not changed\n");
1991     ok( sz == 3, "wrong size returned\n");
1992
1993     sz = 4;
1994     strcpy(buffer,"x");
1995     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1996     ok( r == ERROR_SUCCESS, "wrong return val\n");
1997     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1998     ok( sz == 3, "wrong size returned\n");
1999
2000     sz = 3;
2001     strcpy(buffer,"x");
2002     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2003     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2004     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2005     ok( sz == 3, "wrong size returned\n");
2006
2007     r = MsiSetProperty(hpkg, "SourceDir", "foo");
2008     ok( r == ERROR_SUCCESS, "wrong return val\n");
2009
2010     sz = 4;
2011     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2012     ok( r == ERROR_SUCCESS, "wrong return val\n");
2013     ok( !strcmp(buffer,""), "buffer wrong\n");
2014     ok( sz == 0, "wrong size returned\n");
2015
2016     sz = 4;
2017     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2018     ok( r == ERROR_SUCCESS, "wrong return val\n");
2019     ok( !strcmp(buffer,""), "buffer wrong\n");
2020     ok( sz == 0, "wrong size returned\n");
2021
2022     sz = 4;
2023     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2024     ok( r == ERROR_SUCCESS, "wrong return val\n");
2025     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2026     ok( sz == 3, "wrong size returned\n");
2027
2028     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2029     ok( r == ERROR_SUCCESS, "wrong return val\n");
2030
2031     sz = 0;
2032     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2033     ok( r == ERROR_SUCCESS, "return wrong\n");
2034     ok( sz == 13, "size wrong (%d)\n", sz);
2035
2036     sz = 13;
2037     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2038     ok( r == ERROR_MORE_DATA, "return wrong\n");
2039     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2040
2041     r = MsiSetProperty(hpkg, "property", "value");
2042     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2043
2044     sz = 6;
2045     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2046     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2047     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2048
2049     r = MsiSetProperty(hpkg, "property", NULL);
2050     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2051
2052     sz = 6;
2053     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2055     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2056
2057     MsiCloseHandle( hpkg );
2058     DeleteFile(msifile);
2059 }
2060
2061 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2062 {
2063     MSIHANDLE hview, hrec;
2064     BOOL found;
2065     CHAR buffer[MAX_PATH];
2066     DWORD sz;
2067     UINT r;
2068
2069     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2070     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2071     r = MsiViewExecute(hview, 0);
2072     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2073
2074     found = FALSE;
2075     while (r == ERROR_SUCCESS && !found)
2076     {
2077         r = MsiViewFetch(hview, &hrec);
2078         if (r != ERROR_SUCCESS) break;
2079
2080         sz = MAX_PATH;
2081         r = MsiRecordGetString(hrec, 1, buffer, &sz);
2082         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2083         {
2084             sz = MAX_PATH;
2085             r = MsiRecordGetString(hrec, 2, buffer, &sz);
2086             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2087                 found = TRUE;
2088         }
2089
2090         MsiCloseHandle(hrec);
2091     }
2092
2093     MsiViewClose(hview);
2094     MsiCloseHandle(hview);
2095
2096     return found;
2097 }
2098
2099 static void test_property_table(void)
2100 {
2101     const char *query;
2102     UINT r;
2103     MSIHANDLE hpkg, hdb, hrec;
2104     char buffer[MAX_PATH], package[10];
2105     DWORD sz;
2106     BOOL found;
2107
2108     hdb = create_package_db();
2109     ok( hdb, "failed to create package\n");
2110
2111     r = package_from_db(hdb, &hpkg);
2112     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2113     {
2114         skip("Not enough rights to perform tests\n");
2115         DeleteFile(msifile);
2116         return;
2117     }
2118     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2119
2120     MsiCloseHandle(hdb);
2121
2122     hdb = MsiGetActiveDatabase(hpkg);
2123
2124     query = "CREATE TABLE `_Property` ( "
2125         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2126     r = run_query(hdb, query);
2127     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2128
2129     MsiCloseHandle(hdb);
2130     MsiCloseHandle(hpkg);
2131     DeleteFile(msifile);
2132
2133     hdb = create_package_db();
2134     ok( hdb, "failed to create package\n");
2135
2136     query = "CREATE TABLE `_Property` ( "
2137         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2138     r = run_query(hdb, query);
2139     ok(r == ERROR_SUCCESS, "failed to create table\n");
2140
2141     query = "ALTER `_Property` ADD `foo` INTEGER";
2142     r = run_query(hdb, query);
2143     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2144
2145     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2146     r = run_query(hdb, query);
2147     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2148
2149     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2150     r = run_query(hdb, query);
2151     ok(r == ERROR_SUCCESS, "failed to add column\n");
2152
2153     sprintf(package, "#%i", hdb);
2154     r = MsiOpenPackage(package, &hpkg);
2155     todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2156     if (r == ERROR_SUCCESS)
2157         MsiCloseHandle(hpkg);
2158
2159     r = MsiCloseHandle(hdb);
2160     ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2161
2162     hdb = create_package_db();
2163     ok (hdb, "failed to create package database\n");
2164
2165     r = create_property_table(hdb);
2166     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2167
2168     r = add_property_entry(hdb, "'prop', 'val'");
2169     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2170
2171     r = package_from_db(hdb, &hpkg);
2172     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2173
2174     MsiCloseHandle(hdb);
2175
2176     sz = MAX_PATH;
2177     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2178     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2179     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2180
2181     hdb = MsiGetActiveDatabase(hpkg);
2182
2183     found = find_prop_in_property(hdb, "prop", "val");
2184     ok(found, "prop should be in the _Property table\n");
2185
2186     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2187     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2188
2189     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2190     r = do_query(hdb, query, &hrec);
2191     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2192
2193     found = find_prop_in_property(hdb, "dantes", "mercedes");
2194     ok(found == FALSE, "dantes should not be in the _Property table\n");
2195
2196     sz = MAX_PATH;
2197     lstrcpy(buffer, "aaa");
2198     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2199     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2200     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2201
2202     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2203     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2204
2205     found = find_prop_in_property(hdb, "dantes", "mercedes");
2206     ok(found == TRUE, "dantes should be in the _Property table\n");
2207
2208     MsiCloseHandle(hdb);
2209     MsiCloseHandle(hpkg);
2210     DeleteFile(msifile);
2211 }
2212
2213 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2214 {
2215     MSIHANDLE htab = 0;
2216     UINT res;
2217
2218     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2219     if( res == ERROR_SUCCESS )
2220     {
2221         UINT r;
2222
2223         r = MsiViewExecute( htab, hrec );
2224         if( r != ERROR_SUCCESS )
2225         {
2226             res = r;
2227             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2228         }
2229
2230         r = MsiViewClose( htab );
2231         if( r != ERROR_SUCCESS )
2232             res = r;
2233
2234         r = MsiCloseHandle( htab );
2235         if( r != ERROR_SUCCESS )
2236             res = r;
2237     }
2238     return res;
2239 }
2240
2241 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2242 {
2243     return try_query_param( hdb, szQuery, 0 );
2244 }
2245
2246 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2247 {
2248     MSIHANDLE summary;
2249     UINT r;
2250
2251     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2252     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2253
2254     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2255     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2256
2257     r = MsiSummaryInfoPersist(summary);
2258     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2259
2260     MsiCloseHandle(summary);
2261 }
2262
2263 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2264 {
2265     MSIHANDLE summary;
2266     UINT r;
2267
2268     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2269     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2270
2271     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2272     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2273
2274     r = MsiSummaryInfoPersist(summary);
2275     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2276
2277     MsiCloseHandle(summary);
2278 }
2279
2280 static void test_msipackage(void)
2281 {
2282     MSIHANDLE hdb = 0, hpack = 100;
2283     UINT r;
2284     const char *query;
2285     char name[10];
2286
2287     /* NULL szPackagePath */
2288     r = MsiOpenPackage(NULL, &hpack);
2289     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2290
2291     /* empty szPackagePath */
2292     r = MsiOpenPackage("", &hpack);
2293     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2294     {
2295         skip("Not enough rights to perform tests\n");
2296         return;
2297     }
2298     todo_wine
2299     {
2300         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2301     }
2302
2303     if (r == ERROR_SUCCESS)
2304         MsiCloseHandle(hpack);
2305
2306     /* nonexistent szPackagePath */
2307     r = MsiOpenPackage("nonexistent", &hpack);
2308     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2309
2310     /* NULL hProduct */
2311     r = MsiOpenPackage(msifile, NULL);
2312     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2313
2314     name[0]='#';
2315     name[1]=0;
2316     r = MsiOpenPackage(name, &hpack);
2317     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2318
2319     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2320     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2321
2322     /* database exists, but is emtpy */
2323     sprintf(name, "#%d", hdb);
2324     r = MsiOpenPackage(name, &hpack);
2325     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2326        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2327
2328     query = "CREATE TABLE `Property` ( "
2329             "`Property` CHAR(72), `Value` CHAR(0) "
2330             "PRIMARY KEY `Property`)";
2331     r = try_query(hdb, query);
2332     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2333
2334     query = "CREATE TABLE `InstallExecuteSequence` ("
2335             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2336             "PRIMARY KEY `Action`)";
2337     r = try_query(hdb, query);
2338     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2339
2340     /* a few key tables exist */
2341     sprintf(name, "#%d", hdb);
2342     r = MsiOpenPackage(name, &hpack);
2343     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2344        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2345
2346     MsiCloseHandle(hdb);
2347     DeleteFile(msifile);
2348
2349     /* start with a clean database to show what constitutes a valid package */
2350     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2351     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2352
2353     sprintf(name, "#%d", hdb);
2354
2355     /* The following summary information props must exist:
2356      *  - PID_REVNUMBER
2357      *  - PID_PAGECOUNT
2358      */
2359
2360     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2361     r = MsiOpenPackage(name, &hpack);
2362     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2363        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2364
2365     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2366     r = MsiOpenPackage(name, &hpack);
2367     ok(r == ERROR_SUCCESS,
2368        "Expected ERROR_SUCCESS, got %d\n", r);
2369
2370     MsiCloseHandle(hpack);
2371     MsiCloseHandle(hdb);
2372     DeleteFile(msifile);
2373 }
2374
2375 static void test_formatrecord2(void)
2376 {
2377     MSIHANDLE hpkg, hrec ;
2378     char buffer[0x100];
2379     DWORD sz;
2380     UINT r;
2381
2382     r = package_from_db(create_package_db(), &hpkg);
2383     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2384     {
2385         skip("Not enough rights to perform tests\n");
2386         DeleteFile(msifile);
2387         return;
2388     }
2389     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2390
2391     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2392     ok( r == ERROR_SUCCESS, "set property failed\n");
2393
2394     hrec = MsiCreateRecord(2);
2395     ok(hrec, "create record failed\n");
2396
2397     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2398     ok( r == ERROR_SUCCESS, "format record failed\n");
2399
2400     buffer[0] = 0;
2401     sz = sizeof buffer;
2402     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2403
2404     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2405     r = MsiRecordSetString(hrec, 1, "hoo");
2406     sz = sizeof buffer;
2407     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2408     ok( sz == 3, "size wrong\n");
2409     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2410     ok( r == ERROR_SUCCESS, "format failed\n");
2411
2412     r = MsiRecordSetString(hrec, 0, "x[~]x");
2413     sz = sizeof buffer;
2414     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2415     ok( sz == 3, "size wrong\n");
2416     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2417     ok( r == ERROR_SUCCESS, "format failed\n");
2418
2419     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2420     r = MsiRecordSetString(hrec, 1, "hoo");
2421     sz = sizeof buffer;
2422     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2423     ok( sz == 3, "size wrong\n");
2424     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2425     ok( r == ERROR_SUCCESS, "format failed\n");
2426
2427     r = MsiRecordSetString(hrec, 0, "[\\[]");
2428     sz = sizeof buffer;
2429     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2430     ok( sz == 1, "size wrong\n");
2431     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2432     ok( r == ERROR_SUCCESS, "format failed\n");
2433
2434     SetEnvironmentVariable("FOO", "BAR");
2435     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2436     sz = sizeof buffer;
2437     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2438     ok( sz == 3, "size wrong\n");
2439     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2440     ok( r == ERROR_SUCCESS, "format failed\n");
2441
2442     r = MsiRecordSetString(hrec, 0, "[[1]]");
2443     r = MsiRecordSetString(hrec, 1, "%FOO");
2444     sz = sizeof buffer;
2445     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2446     ok( sz == 3, "size wrong\n");
2447     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2448     ok( r == ERROR_SUCCESS, "format failed\n");
2449
2450     MsiCloseHandle( hrec );
2451     MsiCloseHandle( hpkg );
2452     DeleteFile(msifile);
2453 }
2454
2455 static void test_states(void)
2456 {
2457     MSIHANDLE hpkg;
2458     UINT r;
2459     MSIHANDLE hdb;
2460     INSTALLSTATE state, action;
2461
2462     static const CHAR msifile2[] = "winetest2-package.msi";
2463     static const CHAR msifile3[] = "winetest3-package.msi";
2464     static const CHAR msifile4[] = "winetest4-package.msi";
2465
2466     if (is_process_limited())
2467     {
2468         skip("process is limited\n");
2469         return;
2470     }
2471
2472     hdb = create_package_db();
2473     ok ( hdb, "failed to create package database\n" );
2474
2475     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2476     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2477
2478     r = create_property_table( hdb );
2479     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2480
2481     r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2482     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2483
2484     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2485     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2486
2487     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2488     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2489
2490     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2491     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2492
2493     r = create_install_execute_sequence_table( hdb );
2494     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2495
2496     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2497     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2498
2499     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2500     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2501
2502     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2503     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2504
2505     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2506     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2507
2508     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2509     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2510
2511     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2512     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2513
2514     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2515     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2516
2517     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2518     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2519
2520     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2521     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2522
2523     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2524     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2525
2526     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2527     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2528
2529     r = create_media_table( hdb );
2530     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2531
2532     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2533     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2534
2535     r = create_feature_table( hdb );
2536     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2537
2538     r = create_component_table( hdb );
2539     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2540
2541     /* msidbFeatureAttributesFavorLocal */
2542     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2543     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2544
2545     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2546     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2547     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2548
2549     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2550     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2551     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2552
2553     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2554     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2555     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2556
2557     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2558     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2559     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2560
2561     /* msidbFeatureAttributesFavorSource */
2562     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2563     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2564
2565     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2566     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2567     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2568
2569     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2570     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2571     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2572
2573     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2574     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2575     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2576
2577     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2578     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2579     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2580
2581     /* msidbFeatureAttributesFavorSource */
2582     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2583     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2584
2585     /* msidbFeatureAttributesFavorLocal */
2586     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2587     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2588
2589     /* disabled */
2590     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2591     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2592
2593     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2594     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2595     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2596
2597     /* no feature parent:msidbComponentAttributesLocalOnly */
2598     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2599     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2600
2601     /* msidbFeatureAttributesFavorLocal:removed */
2602     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2603     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2604
2605     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2606     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2607     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2608
2609     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2610     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2611     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2612
2613     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2614     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2615     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2616
2617     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2618     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2619     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2620
2621     /* msidbFeatureAttributesFavorSource:removed */
2622     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2623     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2624
2625     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2626     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2627     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2628
2629     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2630     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2631     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2632
2633     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2634     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2635     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2636
2637     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2638     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2639     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2640
2641     /* msidbFeatureAttributesFavorLocal */
2642     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2643     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2644
2645     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2646     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2647
2648     /* msidbFeatureAttributesFavorSource */
2649     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2650     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2651
2652     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2653     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2654
2655     /* msidbFeatureAttributesFavorAdvertise */
2656     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2657     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2658
2659     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2660     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2661
2662     r = create_feature_components_table( hdb );
2663     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2664
2665     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2666     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2667
2668     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2669     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2670
2671     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2672     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2673
2674     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2675     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2676
2677     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2678     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2679
2680     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2681     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2682
2683     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2684     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2685
2686     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2687     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2688
2689     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2690     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2691
2692     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2693     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2694
2695     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2696     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2697
2698     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2699     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2700
2701     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2702     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2703
2704     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2705     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2706
2707     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2708     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2709
2710     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2711     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2712
2713     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2714     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2715
2716     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2717     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2718
2719     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2720     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2721
2722     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2723     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2724
2725     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2726     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2727
2728     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2729     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2730
2731     r = create_file_table( hdb );
2732     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2733
2734     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2735     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2736
2737     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2738     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2739
2740     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2741     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2742
2743     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2744     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2745
2746     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2747     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2748
2749     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2750     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2751
2752     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2753     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2754
2755     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2756     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2757
2758     /* compressed file */
2759     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2760     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2761
2762     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2763     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2764
2765     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2766     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2767
2768     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2769     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2770
2771     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2772     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2773
2774     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2775     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2776
2777     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2778     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2779
2780     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2781     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2782
2783     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2784     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2785
2786     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2787     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2788
2789     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2790     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2791
2792     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2793     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2794
2795     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2796     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2797
2798     MsiDatabaseCommit(hdb);
2799
2800     /* these properties must not be in the saved msi file */
2801     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2802     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2803
2804     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2805     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2806
2807     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2808     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2809
2810     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2811     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2812
2813     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2814     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2815
2816     r = package_from_db( hdb, &hpkg );
2817     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2818     {
2819         skip("Not enough rights to perform tests\n");
2820         DeleteFile(msifile);
2821         return;
2822     }
2823     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2824
2825     MsiCloseHandle(hdb);
2826
2827     CopyFileA(msifile, msifile2, FALSE);
2828     CopyFileA(msifile, msifile3, FALSE);
2829     CopyFileA(msifile, msifile4, FALSE);
2830
2831     state = 0xdeadbee;
2832     action = 0xdeadbee;
2833     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2834     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "two", &state, &action);
2841     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "three", &state, &action);
2848     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "four", &state, &action);
2855     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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     state = 0xdeadbee;
2860     action = 0xdeadbee;
2861     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2862     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2863     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2864     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2865
2866     state = 0xdeadbee;
2867     action = 0xdeadbee;
2868     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2869     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2870     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2871     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2872
2873     state = 0xdeadbee;
2874     action = 0xdeadbee;
2875     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2876     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2877     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2878     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2879
2880     state = 0xdeadbee;
2881     action = 0xdeadbee;
2882     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2883     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2884     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2885     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2886
2887     state = 0xdeadbee;
2888     action = 0xdeadbee;
2889     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2890     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2891     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2892     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2893
2894     state = 0xdeadbee;
2895     action = 0xdeadbee;
2896     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2897     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2898     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2899     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2900
2901     state = 0xdeadbee;
2902     action = 0xdeadbee;
2903     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2904     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2905     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2906     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2907
2908     state = 0xdeadbee;
2909     action = 0xdeadbee;
2910     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2911     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2912     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2913     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2914
2915     state = 0xdeadbee;
2916     action = 0xdeadbee;
2917     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2918     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2919     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2920     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2921
2922     state = 0xdeadbee;
2923     action = 0xdeadbee;
2924     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2925     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2926     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2927     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2928
2929     state = 0xdeadbee;
2930     action = 0xdeadbee;
2931     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2932     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2933     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2934     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2935
2936     state = 0xdeadbee;
2937     action = 0xdeadbee;
2938     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2939     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2940     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2941     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2942
2943     state = 0xdeadbee;
2944     action = 0xdeadbee;
2945     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2946     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2947     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2948     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2949
2950     state = 0xdeadbee;
2951     action = 0xdeadbee;
2952     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2953     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2954     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2955     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2956
2957     state = 0xdeadbee;
2958     action = 0xdeadbee;
2959     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2960     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2961     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2962     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2963
2964     state = 0xdeadbee;
2965     action = 0xdeadbee;
2966     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2967     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2968     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2969     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2970
2971     state = 0xdeadbee;
2972     action = 0xdeadbee;
2973     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2974     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2975     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2976     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2977
2978     state = 0xdeadbee;
2979     action = 0xdeadbee;
2980     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2981     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2982     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2983     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2984
2985     state = 0xdeadbee;
2986     action = 0xdeadbee;
2987     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2988     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2989     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2990     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2991
2992     state = 0xdeadbee;
2993     action = 0xdeadbee;
2994     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2995     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2996     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2997     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2998
2999     state = 0xdeadbee;
3000     action = 0xdeadbee;
3001     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3002     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3003     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3004     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3005
3006     state = 0xdeadbee;
3007     action = 0xdeadbee;
3008     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3009     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3010     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3011     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3012
3013     state = 0xdeadbee;
3014     action = 0xdeadbee;
3015     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3016     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3017     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3018     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3019
3020     state = 0xdeadbee;
3021     action = 0xdeadbee;
3022     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3023     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3024     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3025     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3026
3027     state = 0xdeadbee;
3028     action = 0xdeadbee;
3029     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3030     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3031     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3032     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3033
3034     state = 0xdeadbee;
3035     action = 0xdeadbee;
3036     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3037     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3038     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3039     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3040
3041     state = 0xdeadbee;
3042     action = 0xdeadbee;
3043     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3044     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3045     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3046     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3047
3048     r = MsiDoAction( hpkg, "CostInitialize");
3049     ok( r == ERROR_SUCCESS, "cost init failed\n");
3050
3051     state = 0xdeadbee;
3052     action = 0xdeadbee;
3053     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
3080     action = 0xdeadbee;
3081     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3082     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3083     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3084     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3085
3086     state = 0xdeadbee;
3087     action = 0xdeadbee;
3088     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3089     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3090     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3091     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3092
3093     state = 0xdeadbee;
3094     action = 0xdeadbee;
3095     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3096     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3097     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3098     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3099
3100     state = 0xdeadbee;
3101     action = 0xdeadbee;
3102     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3103     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3104     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3105     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3106
3107     state = 0xdeadbee;
3108     action = 0xdeadbee;
3109     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3110     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3111     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3112     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3113
3114     state = 0xdeadbee;
3115     action = 0xdeadbee;
3116     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3118     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3119     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3120
3121     state = 0xdeadbee;
3122     action = 0xdeadbee;
3123     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3124     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3125     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3126     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3127
3128     state = 0xdeadbee;
3129     action = 0xdeadbee;
3130     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3131     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3132     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3133     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3134
3135     state = 0xdeadbee;
3136     action = 0xdeadbee;
3137     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3138     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3139     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3140     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3141
3142     state = 0xdeadbee;
3143     action = 0xdeadbee;
3144     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3146     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3147     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3148
3149     state = 0xdeadbee;
3150     action = 0xdeadbee;
3151     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3152     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3153     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3154     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3155
3156     state = 0xdeadbee;
3157     action = 0xdeadbee;
3158     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3160     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3161     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3162
3163     state = 0xdeadbee;
3164     action = 0xdeadbee;
3165     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3167     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3168     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3169
3170     state = 0xdeadbee;
3171     action = 0xdeadbee;
3172     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3174     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3175     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3176
3177     state = 0xdeadbee;
3178     action = 0xdeadbee;
3179     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3181     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3182     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3183
3184     state = 0xdeadbee;
3185     action = 0xdeadbee;
3186     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3188     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3189     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3190
3191     state = 0xdeadbee;
3192     action = 0xdeadbee;
3193     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3195     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3196     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3197
3198     state = 0xdeadbee;
3199     action = 0xdeadbee;
3200     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3202     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3203     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3204
3205     state = 0xdeadbee;
3206     action = 0xdeadbee;
3207     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3209     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3210     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3211
3212     state = 0xdeadbee;
3213     action = 0xdeadbee;
3214     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3216     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3217     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3218
3219     state = 0xdeadbee;
3220     action = 0xdeadbee;
3221     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3223     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3224     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3225
3226     state = 0xdeadbee;
3227     action = 0xdeadbee;
3228     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3230     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3231     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3232
3233     state = 0xdeadbee;
3234     action = 0xdeadbee;
3235     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3237     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3238     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3239
3240     state = 0xdeadbee;
3241     action = 0xdeadbee;
3242     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3243     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3244     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3245     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3246
3247     state = 0xdeadbee;
3248     action = 0xdeadbee;
3249     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3250     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3251     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3252     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3253
3254     state = 0xdeadbee;
3255     action = 0xdeadbee;
3256     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3257     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3258     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3259     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3260
3261     state = 0xdeadbee;
3262     action = 0xdeadbee;
3263     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3264     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3265     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3266     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3267
3268     r = MsiDoAction( hpkg, "FileCost");
3269     ok( r == ERROR_SUCCESS, "file cost failed\n");
3270
3271     state = 0xdeadbee;
3272     action = 0xdeadbee;
3273     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
3300     action = 0xdeadbee;
3301     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3302     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3303     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3304     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3305
3306     state = 0xdeadbee;
3307     action = 0xdeadbee;
3308     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3309     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3310     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3311     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3312
3313     state = 0xdeadbee;
3314     action = 0xdeadbee;
3315     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3316     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3317     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3318     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3319
3320     state = 0xdeadbee;
3321     action = 0xdeadbee;
3322     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3323     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3324     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3325     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3326
3327     state = 0xdeadbee;
3328     action = 0xdeadbee;
3329     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3330     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3331     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3332     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3333
3334     state = 0xdeadbee;
3335     action = 0xdeadbee;
3336     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3337     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3338     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3339     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3340
3341     state = 0xdeadbee;
3342     action = 0xdeadbee;
3343     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3344     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3345     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3346     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3347
3348     state = 0xdeadbee;
3349     action = 0xdeadbee;
3350     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3351     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3352     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3353     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3354
3355     state = 0xdeadbee;
3356     action = 0xdeadbee;
3357     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3358     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3359     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3360     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3361
3362     state = 0xdeadbee;
3363     action = 0xdeadbee;
3364     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3365     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3366     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3367     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3368
3369     state = 0xdeadbee;
3370     action = 0xdeadbee;
3371     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3372     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3373     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3374     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3375
3376     state = 0xdeadbee;
3377     action = 0xdeadbee;
3378     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3379     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3380     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3381     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3382
3383     state = 0xdeadbee;
3384     action = 0xdeadbee;
3385     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3386     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3387     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3388     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3389
3390     state = 0xdeadbee;
3391     action = 0xdeadbee;
3392     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3393     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3394     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3395     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3396
3397     state = 0xdeadbee;
3398     action = 0xdeadbee;
3399     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3400     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3401     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3402     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3403
3404     state = 0xdeadbee;
3405     action = 0xdeadbee;
3406     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3407     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3408     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3409     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3410
3411     state = 0xdeadbee;
3412     action = 0xdeadbee;
3413     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3414     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3415     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3416     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3417
3418     state = 0xdeadbee;
3419     action = 0xdeadbee;
3420     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3421     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3422     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3423     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3424
3425     state = 0xdeadbee;
3426     action = 0xdeadbee;
3427     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3428     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3429     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3430     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3431
3432     state = 0xdeadbee;
3433     action = 0xdeadbee;
3434     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3435     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3436     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3437     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3438
3439     state = 0xdeadbee;
3440     action = 0xdeadbee;
3441     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3442     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3443     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3444     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3445
3446     state = 0xdeadbee;
3447     action = 0xdeadbee;
3448     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3449     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3450     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3451     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3452
3453     state = 0xdeadbee;
3454     action = 0xdeadbee;
3455     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3457     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3458     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3459
3460     state = 0xdeadbee;
3461     action = 0xdeadbee;
3462     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3464     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3465     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3466
3467     state = 0xdeadbee;
3468     action = 0xdeadbee;
3469     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3471     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3472     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3473
3474     state = 0xdeadbee;
3475     action = 0xdeadbee;
3476     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3478     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3479     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3480
3481     state = 0xdeadbee;
3482     action = 0xdeadbee;
3483     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3485     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3486     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3487
3488     r = MsiDoAction( hpkg, "CostFinalize");
3489     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3490
3491     state = 0xdeadbee;
3492     action = 0xdeadbee;
3493     r = MsiGetFeatureState(hpkg, "one", &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_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3497
3498     state = 0xdeadbee;
3499     action = 0xdeadbee;
3500     r = MsiGetFeatureState(hpkg, "two", &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_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3504
3505     state = 0xdeadbee;
3506     action = 0xdeadbee;
3507     r = MsiGetFeatureState(hpkg, "three", &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_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3511
3512     state = 0xdeadbee;
3513     action = 0xdeadbee;
3514     r = MsiGetFeatureState(hpkg, "four", &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_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3518
3519     state = 0xdeadbee;
3520     action = 0xdeadbee;
3521     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3522     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3523     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3524     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3525
3526     state = 0xdeadbee;
3527     action = 0xdeadbee;
3528     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3529     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3530     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3531     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3532
3533     state = 0xdeadbee;
3534     action = 0xdeadbee;
3535     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3536     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3537     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3538     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3539
3540     state = 0xdeadbee;
3541     action = 0xdeadbee;
3542     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3543     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3544     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3545     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3546
3547     state = 0xdeadbee;
3548     action = 0xdeadbee;
3549     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3550     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3551     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3552     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3553
3554     state = 0xdeadbee;
3555     action = 0xdeadbee;
3556     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3557     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3558     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3559     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3560
3561     state = 0xdeadbee;
3562     action = 0xdeadbee;
3563     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3564     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3565     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3566     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3567
3568     state = 0xdeadbee;
3569     action = 0xdeadbee;
3570     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3571     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3572     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3573     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3574
3575     state = 0xdeadbee;
3576     action = 0xdeadbee;
3577     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3578     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3579     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3580     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3581
3582     state = 0xdeadbee;
3583     action = 0xdeadbee;
3584     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3585     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3586     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3587     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3588
3589     state = 0xdeadbee;
3590     action = 0xdeadbee;
3591     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3592     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3593     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3594     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3595
3596     state = 0xdeadbee;
3597     action = 0xdeadbee;
3598     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3599     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3600     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3601     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3602
3603     state = 0xdeadbee;
3604     action = 0xdeadbee;
3605     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3606     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3607     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3608     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3609
3610     state = 0xdeadbee;
3611     action = 0xdeadbee;
3612     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3613     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3614     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3615     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3616
3617     state = 0xdeadbee;
3618     action = 0xdeadbee;
3619     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3620     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3621     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3622     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3623
3624     state = 0xdeadbee;
3625     action = 0xdeadbee;
3626     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3627     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3628     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3629     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3630
3631     state = 0xdeadbee;
3632     action = 0xdeadbee;
3633     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3635     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3636     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3637
3638     state = 0xdeadbee;
3639     action = 0xdeadbee;
3640     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3641     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3642     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3643     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3644
3645     state = 0xdeadbee;
3646     action = 0xdeadbee;
3647     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3648     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3649     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3650     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3651
3652     state = 0xdeadbee;
3653     action = 0xdeadbee;
3654     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3655     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3656     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3657     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3658
3659     state = 0xdeadbee;
3660     action = 0xdeadbee;
3661     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3663     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3664     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3665
3666     state = 0xdeadbee;
3667     action = 0xdeadbee;
3668     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3669     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3670     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3671     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3672
3673     state = 0xdeadbee;
3674     action = 0xdeadbee;
3675     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3676     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3677     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3678     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3679
3680     state = 0xdeadbee;
3681     action = 0xdeadbee;
3682     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3683     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3684     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3685     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3686
3687     state = 0xdeadbee;
3688     action = 0xdeadbee;
3689     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3690     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3691     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3692     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3693
3694     state = 0xdeadbee;
3695     action = 0xdeadbee;
3696     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3697     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3698     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3699     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3700
3701     state = 0xdeadbee;
3702     action = 0xdeadbee;
3703     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3705     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3706     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3707
3708     MsiCloseHandle( hpkg );
3709
3710     /* publish the features and components */
3711     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3712     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3713
3714     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3715     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3716
3717     /* these properties must not be in the saved msi file */
3718     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3719     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3720
3721     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3722     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3723
3724     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3725     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3726
3727     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3728     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3729
3730     r = package_from_db( hdb, &hpkg );
3731     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3732
3733     MsiCloseHandle(hdb);
3734
3735     state = 0xdeadbee;
3736     action = 0xdeadbee;
3737     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3738     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "two", &state, &action);
3745     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "three", &state, &action);
3752     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "four", &state, &action);
3759     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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     state = 0xdeadbee;
3764     action = 0xdeadbee;
3765     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3766     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3767     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3768     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3769
3770     state = 0xdeadbee;
3771     action = 0xdeadbee;
3772     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3773     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3774     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3775     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3776
3777     state = 0xdeadbee;
3778     action = 0xdeadbee;
3779     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3780     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3781     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3782     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3783
3784     state = 0xdeadbee;
3785     action = 0xdeadbee;
3786     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3787     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3788     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3789     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3790
3791     state = 0xdeadbee;
3792     action = 0xdeadbee;
3793     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3794     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3795     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3796     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3797
3798     state = 0xdeadbee;
3799     action = 0xdeadbee;
3800     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3801     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3802     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3803     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3804
3805     state = 0xdeadbee;
3806     action = 0xdeadbee;
3807     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3808     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3809     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3810     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3811
3812     state = 0xdeadbee;
3813     action = 0xdeadbee;
3814     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3815     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3816     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3817     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3818
3819     state = 0xdeadbee;
3820     action = 0xdeadbee;
3821     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3822     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3823     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3824     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3825
3826     state = 0xdeadbee;
3827     action = 0xdeadbee;
3828     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3829     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3830     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3831     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3832
3833     state = 0xdeadbee;
3834     action = 0xdeadbee;
3835     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3836     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3837     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3838     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3839
3840     state = 0xdeadbee;
3841     action = 0xdeadbee;
3842     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3843     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3844     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3845     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3846
3847     state = 0xdeadbee;
3848     action = 0xdeadbee;
3849     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3850     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3851     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3852     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3853
3854     state = 0xdeadbee;
3855     action = 0xdeadbee;
3856     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3857     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3858     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3859     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3860
3861     state = 0xdeadbee;
3862     action = 0xdeadbee;
3863     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3864     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3865     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3866     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3867
3868     state = 0xdeadbee;
3869     action = 0xdeadbee;
3870     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3871     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3872     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3873     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3874
3875     state = 0xdeadbee;
3876     action = 0xdeadbee;
3877     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3878     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3879     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3880     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3881
3882     state = 0xdeadbee;
3883     action = 0xdeadbee;
3884     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3885     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3886     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3887     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3888
3889     state = 0xdeadbee;
3890     action = 0xdeadbee;
3891     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3892     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3893     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3894     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3895
3896     state = 0xdeadbee;
3897     action = 0xdeadbee;
3898     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3899     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3900     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3901     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3902
3903     state = 0xdeadbee;
3904     action = 0xdeadbee;
3905     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3906     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3907     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3908     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3909
3910     state = 0xdeadbee;
3911     action = 0xdeadbee;
3912     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3913     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3914     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3915     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3916
3917     state = 0xdeadbee;
3918     action = 0xdeadbee;
3919     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3920     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3921     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3922     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3923
3924     state = 0xdeadbee;
3925     action = 0xdeadbee;
3926     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3927     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3928     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3929     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3930
3931     state = 0xdeadbee;
3932     action = 0xdeadbee;
3933     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3934     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3935     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3936     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3937
3938     state = 0xdeadbee;
3939     action = 0xdeadbee;
3940     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3941     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3942     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3943     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3944
3945     state = 0xdeadbee;
3946     action = 0xdeadbee;
3947     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3948     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3949     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3950     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3951
3952     r = MsiDoAction( hpkg, "CostInitialize");
3953     ok( r == ERROR_SUCCESS, "cost init failed\n");
3954
3955     state = 0xdeadbee;
3956     action = 0xdeadbee;
3957     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
3984     action = 0xdeadbee;
3985     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3986     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3987     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3988     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3989
3990     state = 0xdeadbee;
3991     action = 0xdeadbee;
3992     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3993     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3994     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3995     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3996
3997     state = 0xdeadbee;
3998     action = 0xdeadbee;
3999     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4000     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4001     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4002     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4003
4004     state = 0xdeadbee;
4005     action = 0xdeadbee;
4006     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4007     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4008     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4009     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4010
4011     state = 0xdeadbee;
4012     action = 0xdeadbee;
4013     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4014     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4015     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4016     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4017
4018     state = 0xdeadbee;
4019     action = 0xdeadbee;
4020     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4021     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4022     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4023     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4024
4025     state = 0xdeadbee;
4026     action = 0xdeadbee;
4027     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4028     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4029     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4030     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4031
4032     state = 0xdeadbee;
4033     action = 0xdeadbee;
4034     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4035     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4036     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4037     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4038
4039     state = 0xdeadbee;
4040     action = 0xdeadbee;
4041     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4042     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4043     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4044     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4045
4046     state = 0xdeadbee;
4047     action = 0xdeadbee;
4048     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4049     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4050     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4051     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4052
4053     state = 0xdeadbee;
4054     action = 0xdeadbee;
4055     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4056     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4057     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4058     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4059
4060     state = 0xdeadbee;
4061     action = 0xdeadbee;
4062     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4063     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4064     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4065     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4066
4067     state = 0xdeadbee;
4068     action = 0xdeadbee;
4069     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4070     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4071     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4072     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4073
4074     state = 0xdeadbee;
4075     action = 0xdeadbee;
4076     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4080
4081     state = 0xdeadbee;
4082     action = 0xdeadbee;
4083     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4087
4088     state = 0xdeadbee;
4089     action = 0xdeadbee;
4090     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4094
4095     state = 0xdeadbee;
4096     action = 0xdeadbee;
4097     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4101
4102     state = 0xdeadbee;
4103     action = 0xdeadbee;
4104     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4108
4109     state = 0xdeadbee;
4110     action = 0xdeadbee;
4111     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4115
4116     state = 0xdeadbee;
4117     action = 0xdeadbee;
4118     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4122
4123     state = 0xdeadbee;
4124     action = 0xdeadbee;
4125     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4126     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4127     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4128     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4129
4130     state = 0xdeadbee;
4131     action = 0xdeadbee;
4132     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4134     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4135     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4136
4137     state = 0xdeadbee;
4138     action = 0xdeadbee;
4139     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4140     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4141     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4142     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4143
4144     state = 0xdeadbee;
4145     action = 0xdeadbee;
4146     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4147     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4148     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4149     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4150
4151     state = 0xdeadbee;
4152     action = 0xdeadbee;
4153     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4154     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4155     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4156     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4157
4158     state = 0xdeadbee;
4159     action = 0xdeadbee;
4160     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4164
4165     state = 0xdeadbee;
4166     action = 0xdeadbee;
4167     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4171
4172     r = MsiDoAction( hpkg, "FileCost");
4173     ok( r == ERROR_SUCCESS, "file cost failed\n");
4174
4175     state = 0xdeadbee;
4176     action = 0xdeadbee;
4177     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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     state = 0xdeadbee;
4197     action = 0xdeadbee;
4198     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4199     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4200     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4201     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4202
4203     state = 0xdeadbee;
4204     action = 0xdeadbee;
4205     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4206     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4207     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4208     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4209
4210     state = 0xdeadbee;
4211     action = 0xdeadbee;
4212     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4213     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4214     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4215     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4216
4217     state = 0xdeadbee;
4218     action = 0xdeadbee;
4219     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4220     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4221     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4222     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4223
4224     state = 0xdeadbee;
4225     action = 0xdeadbee;
4226     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4227     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4228     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4229     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4230
4231     state = 0xdeadbee;
4232     action = 0xdeadbee;
4233     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4234     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4235     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4236     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4237
4238     state = 0xdeadbee;
4239     action = 0xdeadbee;
4240     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4241     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4242     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4243     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4244
4245     state = 0xdeadbee;
4246     action = 0xdeadbee;
4247     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4248     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4249     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4250     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4251
4252     state = 0xdeadbee;
4253     action = 0xdeadbee;
4254     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4255     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4256     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4257     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4258
4259     state = 0xdeadbee;
4260     action = 0xdeadbee;
4261     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4262     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4263     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4264     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4265
4266     state = 0xdeadbee;
4267     action = 0xdeadbee;
4268     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4269     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4270     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4271     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4272
4273     state = 0xdeadbee;
4274     action = 0xdeadbee;
4275     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4276     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4277     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4278     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4279
4280     state = 0xdeadbee;
4281     action = 0xdeadbee;
4282     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4283     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4284     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4285     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4286
4287     state = 0xdeadbee;
4288     action = 0xdeadbee;
4289     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4290     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4291     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4292     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4293
4294     state = 0xdeadbee;
4295     action = 0xdeadbee;
4296     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4297     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4298     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4299     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4300
4301     state = 0xdeadbee;
4302     action = 0xdeadbee;
4303     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4304     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4305     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4306     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4307
4308     state = 0xdeadbee;
4309     action = 0xdeadbee;
4310     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4312     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4313     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4314
4315     state = 0xdeadbee;
4316     action = 0xdeadbee;
4317     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4319     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4320     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4321
4322     state = 0xdeadbee;
4323     action = 0xdeadbee;
4324     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4326     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4327     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4328
4329     state = 0xdeadbee;
4330     action = 0xdeadbee;
4331     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4333     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4334     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4335
4336     state = 0xdeadbee;
4337     action = 0xdeadbee;
4338     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4340     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4341     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4342
4343     state = 0xdeadbee;
4344     action = 0xdeadbee;
4345     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4347     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4348     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4349
4350     state = 0xdeadbee;
4351     action = 0xdeadbee;
4352     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4354     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4355     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4356
4357     state = 0xdeadbee;
4358     action = 0xdeadbee;
4359     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4361     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4362     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4363
4364     state = 0xdeadbee;
4365     action = 0xdeadbee;
4366     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4368     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4369     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4370
4371     state = 0xdeadbee;
4372     action = 0xdeadbee;
4373     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4375     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4376     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4377
4378     state = 0xdeadbee;
4379     action = 0xdeadbee;
4380     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4382     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4383     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4384
4385     r = MsiDoAction( hpkg, "CostFinalize");
4386     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4387
4388     state = 0xdeadbee;
4389     action = 0xdeadbee;
4390     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4391     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4392     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4393     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4394
4395     state = 0xdeadbee;
4396     action = 0xdeadbee;
4397     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4398     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4399     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4400     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4401
4402     state = 0xdeadbee;
4403     action = 0xdeadbee;
4404     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4405     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4406     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4407     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4408
4409     state = 0xdeadbee;
4410     action = 0xdeadbee;
4411     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4412     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4413     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4414     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4415
4416     state = 0xdeadbee;
4417     action = 0xdeadbee;
4418     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4419     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4420     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4421     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4422
4423     state = 0xdeadbee;
4424     action = 0xdeadbee;
4425     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4426     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4427     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4428     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4429
4430     state = 0xdeadbee;
4431     action = 0xdeadbee;
4432     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4433     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4434     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4435     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4436
4437     state = 0xdeadbee;
4438     action = 0xdeadbee;
4439     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4440     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4441     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4442     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4443
4444     state = 0xdeadbee;
4445     action = 0xdeadbee;
4446     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4448     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4449     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4450
4451     state = 0xdeadbee;
4452     action = 0xdeadbee;
4453     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4455     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4456     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4457
4458     state = 0xdeadbee;
4459     action = 0xdeadbee;
4460     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4461     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4462     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4463     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4464
4465     state = 0xdeadbee;
4466     action = 0xdeadbee;
4467     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4468     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4469     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4470     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4471
4472     state = 0xdeadbee;
4473     action = 0xdeadbee;
4474     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4475     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4476     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4477     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4478
4479     state = 0xdeadbee;
4480     action = 0xdeadbee;
4481     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4482     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4483     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4484     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4485
4486     state = 0xdeadbee;
4487     action = 0xdeadbee;
4488     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4489     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4490     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4491     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4492
4493     state = 0xdeadbee;
4494     action = 0xdeadbee;
4495     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4496     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4497     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4498     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4499
4500     state = 0xdeadbee;
4501     action = 0xdeadbee;
4502     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4503     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4504     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4505     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4506
4507     state = 0xdeadbee;
4508     action = 0xdeadbee;
4509     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4510     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4511     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4512     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4513
4514     state = 0xdeadbee;
4515     action = 0xdeadbee;
4516     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4517     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4518     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4519     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4520
4521     state = 0xdeadbee;
4522     action = 0xdeadbee;
4523     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4524     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4525     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4526     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4527
4528     state = 0xdeadbee;
4529     action = 0xdeadbee;
4530     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4531     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4532     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4533     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4534
4535     state = 0xdeadbee;
4536     action = 0xdeadbee;
4537     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4538     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4539     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4540     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4541
4542     state = 0xdeadbee;
4543     action = 0xdeadbee;
4544     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4545     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4546     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4547     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4548
4549     state = 0xdeadbee;
4550     action = 0xdeadbee;
4551     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4552     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4553     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4554     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4555
4556     state = 0xdeadbee;
4557     action = 0xdeadbee;
4558     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4559     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4560     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4561     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4562
4563     state = 0xdeadbee;
4564     action = 0xdeadbee;
4565     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4566     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4567     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4568     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4569
4570     state = 0xdeadbee;
4571     action = 0xdeadbee;
4572     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4573     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4574     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4575     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4576
4577     state = 0xdeadbee;
4578     action = 0xdeadbee;
4579     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4580     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4581     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4582     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4583
4584     state = 0xdeadbee;
4585     action = 0xdeadbee;
4586     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4587     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4588     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4589     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4590
4591     state = 0xdeadbee;
4592     action = 0xdeadbee;
4593     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4594     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4595     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4596     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4597
4598     state = 0xdeadbee;
4599     action = 0xdeadbee;
4600     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4601     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4602     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4603     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4604
4605     MsiCloseHandle(hpkg);
4606
4607     /* uninstall the product */
4608     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4609     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4610
4611     /* all features installed locally */
4612     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4613     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4614
4615     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4616     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4617
4618     /* these properties must not be in the saved msi file */
4619     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4620     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4621
4622     r = package_from_db( hdb, &hpkg );
4623     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
4624
4625     state = 0xdeadbee;
4626     action = 0xdeadbee;
4627     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4628     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "two", &state, &action);
4635     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "three", &state, &action);
4642     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "four", &state, &action);
4649     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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     state = 0xdeadbee;
4654     action = 0xdeadbee;
4655     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4656     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4657     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4658     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4659
4660     state = 0xdeadbee;
4661     action = 0xdeadbee;
4662     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4663     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4664     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4665     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4666
4667     state = 0xdeadbee;
4668     action = 0xdeadbee;
4669     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4670     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4671     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4672     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4673
4674     state = 0xdeadbee;
4675     action = 0xdeadbee;
4676     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4677     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4678     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4679     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4680
4681     state = 0xdeadbee;
4682     action = 0xdeadbee;
4683     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4684     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4685     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4686     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4687
4688     state = 0xdeadbee;
4689     action = 0xdeadbee;
4690     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4691     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4692     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4693     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4694
4695     state = 0xdeadbee;
4696     action = 0xdeadbee;
4697     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4698     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4699     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4700     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4701
4702     state = 0xdeadbee;
4703     action = 0xdeadbee;
4704     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4705     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4706     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4707     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4708
4709     state = 0xdeadbee;
4710     action = 0xdeadbee;
4711     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4712     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4713     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4714     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4715
4716     state = 0xdeadbee;
4717     action = 0xdeadbee;
4718     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4719     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4720     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4721     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4722
4723     state = 0xdeadbee;
4724     action = 0xdeadbee;
4725     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4726     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4727     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4728     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4729
4730     state = 0xdeadbee;
4731     action = 0xdeadbee;
4732     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4733     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4734     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4735     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4736
4737     state = 0xdeadbee;
4738     action = 0xdeadbee;
4739     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4740     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4741     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4742     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4743
4744     state = 0xdeadbee;
4745     action = 0xdeadbee;
4746     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4747     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4748     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4749     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4750
4751     state = 0xdeadbee;
4752     action = 0xdeadbee;
4753     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4754     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4755     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4756     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4757
4758     state = 0xdeadbee;
4759     action = 0xdeadbee;
4760     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4761     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4762     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4763     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4764
4765     state = 0xdeadbee;
4766     action = 0xdeadbee;
4767     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4768     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4769     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4770     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4771
4772     state = 0xdeadbee;
4773     action = 0xdeadbee;
4774     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4775     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4776     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4777     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4778
4779     state = 0xdeadbee;
4780     action = 0xdeadbee;
4781     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4782     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4783     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4784     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4785
4786     state = 0xdeadbee;
4787     action = 0xdeadbee;
4788     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4789     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4790     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4791     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4792
4793     state = 0xdeadbee;
4794     action = 0xdeadbee;
4795     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4796     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4797     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4798     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4799
4800     state = 0xdeadbee;
4801     action = 0xdeadbee;
4802     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4803     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4804     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4805     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4806
4807     state = 0xdeadbee;
4808     action = 0xdeadbee;
4809     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4810     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4811     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4812     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4813
4814     state = 0xdeadbee;
4815     action = 0xdeadbee;
4816     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4817     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4818     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4819     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4820
4821     state = 0xdeadbee;
4822     action = 0xdeadbee;
4823     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4824     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4825     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4826     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4827
4828     state = 0xdeadbee;
4829     action = 0xdeadbee;
4830     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4831     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4832     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4833     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4834
4835     state = 0xdeadbee;
4836     action = 0xdeadbee;
4837     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4838     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4839     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4840     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4841
4842     r = MsiDoAction( hpkg, "CostInitialize");
4843     ok( r == ERROR_SUCCESS, "cost init failed\n");
4844
4845     state = 0xdeadbee;
4846     action = 0xdeadbee;
4847     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
4874     action = 0xdeadbee;
4875     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4876     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4877     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4878     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4879
4880     state = 0xdeadbee;
4881     action = 0xdeadbee;
4882     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4883     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4884     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4885     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4886
4887     state = 0xdeadbee;
4888     action = 0xdeadbee;
4889     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4890     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4891     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4892     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4893
4894     state = 0xdeadbee;
4895     action = 0xdeadbee;
4896     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4897     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4898     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4899     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4900
4901     state = 0xdeadbee;
4902     action = 0xdeadbee;
4903     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4904     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4905     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4906     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4907
4908     state = 0xdeadbee;
4909     action = 0xdeadbee;
4910     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4911     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4912     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4913     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4914
4915     state = 0xdeadbee;
4916     action = 0xdeadbee;
4917     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4918     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4919     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4920     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4921
4922     state = 0xdeadbee;
4923     action = 0xdeadbee;
4924     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4925     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4926     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4927     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4928
4929     state = 0xdeadbee;
4930     action = 0xdeadbee;
4931     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4932     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4933     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4934     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4935
4936     state = 0xdeadbee;
4937     action = 0xdeadbee;
4938     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4939     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4940     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4941     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4942
4943     state = 0xdeadbee;
4944     action = 0xdeadbee;
4945     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4946     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4947     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4948     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4949
4950     state = 0xdeadbee;
4951     action = 0xdeadbee;
4952     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4953     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4954     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4955     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4956
4957     state = 0xdeadbee;
4958     action = 0xdeadbee;
4959     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4960     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4961     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4962     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4963
4964     state = 0xdeadbee;
4965     action = 0xdeadbee;
4966     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4967     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4968     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4969     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4970
4971     state = 0xdeadbee;
4972     action = 0xdeadbee;
4973     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4974     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4975     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4976     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4977
4978     state = 0xdeadbee;
4979     action = 0xdeadbee;
4980     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4981     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4982     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4983     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4984
4985     state = 0xdeadbee;
4986     action = 0xdeadbee;
4987     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4988     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4989     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4990     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4991
4992     state = 0xdeadbee;
4993     action = 0xdeadbee;
4994     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4996     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4997     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4998
4999     state = 0xdeadbee;
5000     action = 0xdeadbee;
5001     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5002     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5003     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5004     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5005
5006     state = 0xdeadbee;
5007     action = 0xdeadbee;
5008     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5009     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5010     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5011     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5012
5013     state = 0xdeadbee;
5014     action = 0xdeadbee;
5015     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5017     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5018     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5019
5020     state = 0xdeadbee;
5021     action = 0xdeadbee;
5022     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5023     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5024     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5025     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5026
5027     state = 0xdeadbee;
5028     action = 0xdeadbee;
5029     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5030     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5031     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5032     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5033
5034     state = 0xdeadbee;
5035     action = 0xdeadbee;
5036     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5037     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5038     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5039     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5040
5041     state = 0xdeadbee;
5042     action = 0xdeadbee;
5043     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5045     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5046     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5047
5048     state = 0xdeadbee;
5049     action = 0xdeadbee;
5050     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5052     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5053     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5054
5055     state = 0xdeadbee;
5056     action = 0xdeadbee;
5057     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5059     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5060     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5061
5062     r = MsiDoAction( hpkg, "FileCost");
5063     ok( r == ERROR_SUCCESS, "file cost failed\n");
5064
5065     state = 0xdeadbee;
5066     action = 0xdeadbee;
5067     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
5094     action = 0xdeadbee;
5095     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5096     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5097     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5098     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5099
5100     state = 0xdeadbee;
5101     action = 0xdeadbee;
5102     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5103     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5104     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5105     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5106
5107     state = 0xdeadbee;
5108     action = 0xdeadbee;
5109     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5110     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5111     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5112     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5113
5114     state = 0xdeadbee;
5115     action = 0xdeadbee;
5116     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5118     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5119     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5120
5121     state = 0xdeadbee;
5122     action = 0xdeadbee;
5123     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5124     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5125     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5126     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5127
5128     state = 0xdeadbee;
5129     action = 0xdeadbee;
5130     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5131     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5132     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5133     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5134
5135     state = 0xdeadbee;
5136     action = 0xdeadbee;
5137     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5138     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5139     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5140     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5141
5142     state = 0xdeadbee;
5143     action = 0xdeadbee;
5144     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5146     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5147     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5148
5149     state = 0xdeadbee;
5150     action = 0xdeadbee;
5151     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5152     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5153     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5154     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5155
5156     state = 0xdeadbee;
5157     action = 0xdeadbee;
5158     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5160     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5161     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5162
5163     state = 0xdeadbee;
5164     action = 0xdeadbee;
5165     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5167     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5168     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5169
5170     state = 0xdeadbee;
5171     action = 0xdeadbee;
5172     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5174     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5175     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5176
5177     state = 0xdeadbee;
5178     action = 0xdeadbee;
5179     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5181     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5182     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5183
5184     state = 0xdeadbee;
5185     action = 0xdeadbee;
5186     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5188     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5189     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5190
5191     state = 0xdeadbee;
5192     action = 0xdeadbee;
5193     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5195     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5196     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5197
5198     state = 0xdeadbee;
5199     action = 0xdeadbee;
5200     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5202     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5203     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5204
5205     state = 0xdeadbee;
5206     action = 0xdeadbee;
5207     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5209     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5210     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5211
5212     state = 0xdeadbee;
5213     action = 0xdeadbee;
5214     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5216     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5217     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5218
5219     state = 0xdeadbee;
5220     action = 0xdeadbee;
5221     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5223     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5224     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5225
5226     state = 0xdeadbee;
5227     action = 0xdeadbee;
5228     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5230     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5231     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5232
5233     state = 0xdeadbee;
5234     action = 0xdeadbee;
5235     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5237     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5238     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5239
5240     state = 0xdeadbee;
5241     action = 0xdeadbee;
5242     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5243     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5244     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5245     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5246
5247     state = 0xdeadbee;
5248     action = 0xdeadbee;
5249     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5250     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5251     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5252     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5253
5254     state = 0xdeadbee;
5255     action = 0xdeadbee;
5256     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5257     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5258     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5259     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5260
5261     state = 0xdeadbee;
5262     action = 0xdeadbee;
5263     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5264     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5265     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5266     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5267
5268     state = 0xdeadbee;
5269     action = 0xdeadbee;
5270     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5271     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5272     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5273     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5274
5275     state = 0xdeadbee;
5276     action = 0xdeadbee;
5277     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5278     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5279     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5280     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5281
5282     r = MsiDoAction( hpkg, "CostFinalize");
5283     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5284
5285     state = 0xdeadbee;
5286     action = 0xdeadbee;
5287     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5288     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5289     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5290     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5291
5292     state = 0xdeadbee;
5293     action = 0xdeadbee;
5294     r = MsiGetFeatureState(hpkg, "two", &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( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5298
5299     state = 0xdeadbee;
5300     action = 0xdeadbee;
5301     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5302     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5303     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5304     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5305
5306     state = 0xdeadbee;
5307     action = 0xdeadbee;
5308     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5309     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5310     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5311     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5312
5313     state = 0xdeadbee;
5314     action = 0xdeadbee;
5315     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5316     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5317     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5318     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5319
5320     state = 0xdeadbee;
5321     action = 0xdeadbee;
5322     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5323     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5324     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5325     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5326
5327     state = 0xdeadbee;
5328     action = 0xdeadbee;
5329     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5330     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5331     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5332     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5333
5334     state = 0xdeadbee;
5335     action = 0xdeadbee;
5336     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5337     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5338     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5339     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5340
5341     state = 0xdeadbee;
5342     action = 0xdeadbee;
5343     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5344     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5345     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5346     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5347
5348     state = 0xdeadbee;
5349     action = 0xdeadbee;
5350     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5351     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5352     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5353     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5354
5355     state = 0xdeadbee;
5356     action = 0xdeadbee;
5357     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5358     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5359     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5360     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5361
5362     state = 0xdeadbee;
5363     action = 0xdeadbee;
5364     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5365     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5366     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5367     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5368
5369     state = 0xdeadbee;
5370     action = 0xdeadbee;
5371     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5372     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5373     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5374     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5375
5376     state = 0xdeadbee;
5377     action = 0xdeadbee;
5378     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5379     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5380     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5381     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5382
5383     state = 0xdeadbee;
5384     action = 0xdeadbee;
5385     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5386     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5387     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5388     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5389
5390     state = 0xdeadbee;
5391     action = 0xdeadbee;
5392     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5393     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5394     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5395     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5396
5397     state = 0xdeadbee;
5398     action = 0xdeadbee;
5399     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5400     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5401     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5402     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5403
5404     state = 0xdeadbee;
5405     action = 0xdeadbee;
5406     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5407     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5408     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5409     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5410
5411     state = 0xdeadbee;
5412     action = 0xdeadbee;
5413     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5414     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5415     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5416     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5417
5418     state = 0xdeadbee;
5419     action = 0xdeadbee;
5420     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5421     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5422     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5423     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5424
5425     state = 0xdeadbee;
5426     action = 0xdeadbee;
5427     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5428     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5429     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5430     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5431
5432     state = 0xdeadbee;
5433     action = 0xdeadbee;
5434     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5435     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5436     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5437     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5438
5439     state = 0xdeadbee;
5440     action = 0xdeadbee;
5441     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5442     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5443     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5444     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5445
5446     state = 0xdeadbee;
5447     action = 0xdeadbee;
5448     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5449     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5450     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5451     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5452
5453     state = 0xdeadbee;
5454     action = 0xdeadbee;
5455     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5457     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5458     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5459
5460     state = 0xdeadbee;
5461     action = 0xdeadbee;
5462     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5464     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5465     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5466
5467     state = 0xdeadbee;
5468     action = 0xdeadbee;
5469     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5471     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5472     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5473
5474     state = 0xdeadbee;
5475     action = 0xdeadbee;
5476     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5478     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5479     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5480
5481     state = 0xdeadbee;
5482     action = 0xdeadbee;
5483     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5485     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5486     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5487
5488     state = 0xdeadbee;
5489     action = 0xdeadbee;
5490     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5492     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5493     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5494
5495     state = 0xdeadbee;
5496     action = 0xdeadbee;
5497     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5499     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5500     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5501
5502     MsiCloseHandle(hpkg);
5503
5504     /* uninstall the product */
5505     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5506     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5507
5508     /* all features installed from source */
5509     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5511
5512     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5513     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5514
5515     /* this property must not be in the saved msi file */
5516     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5517     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5518
5519     r = package_from_db( hdb, &hpkg );
5520     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5521
5522     state = 0xdeadbee;
5523     action = 0xdeadbee;
5524     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5525     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "two", &state, &action);
5532     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "three", &state, &action);
5539     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "four", &state, &action);
5546     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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     state = 0xdeadbee;
5551     action = 0xdeadbee;
5552     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5553     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5554     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5555     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5556
5557     state = 0xdeadbee;
5558     action = 0xdeadbee;
5559     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5560     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5561     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5562     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5563
5564     state = 0xdeadbee;
5565     action = 0xdeadbee;
5566     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5567     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5568     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5569     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5570
5571     state = 0xdeadbee;
5572     action = 0xdeadbee;
5573     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5574     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5575     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5576     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5577
5578     state = 0xdeadbee;
5579     action = 0xdeadbee;
5580     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5581     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5582     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5583     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5584
5585     state = 0xdeadbee;
5586     action = 0xdeadbee;
5587     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5588     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5589     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5590     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5591
5592     state = 0xdeadbee;
5593     action = 0xdeadbee;
5594     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5595     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5596     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5597     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5598
5599     state = 0xdeadbee;
5600     action = 0xdeadbee;
5601     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5602     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5603     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5604     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5605
5606     state = 0xdeadbee;
5607     action = 0xdeadbee;
5608     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5609     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5610     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5611     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5612
5613     state = 0xdeadbee;
5614     action = 0xdeadbee;
5615     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5616     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5617     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5618     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5619
5620     state = 0xdeadbee;
5621     action = 0xdeadbee;
5622     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5623     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5624     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5625     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5626
5627     state = 0xdeadbee;
5628     action = 0xdeadbee;
5629     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5630     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5631     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5632     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5633
5634     state = 0xdeadbee;
5635     action = 0xdeadbee;
5636     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5637     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5638     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5639     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5640
5641     state = 0xdeadbee;
5642     action = 0xdeadbee;
5643     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5644     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5645     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5646     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5647
5648     state = 0xdeadbee;
5649     action = 0xdeadbee;
5650     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5651     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5652     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5653     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5654
5655     state = 0xdeadbee;
5656     action = 0xdeadbee;
5657     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5658     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5659     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5660     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5661
5662     state = 0xdeadbee;
5663     action = 0xdeadbee;
5664     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5665     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5666     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5667     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5668
5669     state = 0xdeadbee;
5670     action = 0xdeadbee;
5671     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5672     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5673     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5674     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5675
5676     state = 0xdeadbee;
5677     action = 0xdeadbee;
5678     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5679     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5680     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5681     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5682
5683     state = 0xdeadbee;
5684     action = 0xdeadbee;
5685     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5686     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5687     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5688     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5689
5690     state = 0xdeadbee;
5691     action = 0xdeadbee;
5692     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5693     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5694     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5695     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5696
5697     state = 0xdeadbee;
5698     action = 0xdeadbee;
5699     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5700     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5701     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5702     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5703
5704     state = 0xdeadbee;
5705     action = 0xdeadbee;
5706     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5707     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5708     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5709     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5710
5711     state = 0xdeadbee;
5712     action = 0xdeadbee;
5713     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5714     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5715     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5716     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5717
5718     state = 0xdeadbee;
5719     action = 0xdeadbee;
5720     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5721     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5722     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5723     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5724
5725     state = 0xdeadbee;
5726     action = 0xdeadbee;
5727     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5728     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5729     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5730     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5731
5732     state = 0xdeadbee;
5733     action = 0xdeadbee;
5734     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5735     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5736     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5737     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5738
5739     r = MsiDoAction( hpkg, "CostInitialize");
5740     ok( r == ERROR_SUCCESS, "cost init failed\n");
5741
5742     state = 0xdeadbee;
5743     action = 0xdeadbee;
5744     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
5771     action = 0xdeadbee;
5772     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5773     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5774     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5775     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5776
5777     state = 0xdeadbee;
5778     action = 0xdeadbee;
5779     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5780     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5781     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5782     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5783
5784     state = 0xdeadbee;
5785     action = 0xdeadbee;
5786     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5787     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5788     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5789     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5790
5791     state = 0xdeadbee;
5792     action = 0xdeadbee;
5793     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5794     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5795     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5796     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5797
5798     state = 0xdeadbee;
5799     action = 0xdeadbee;
5800     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5801     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5802     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5803     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5804
5805     state = 0xdeadbee;
5806     action = 0xdeadbee;
5807     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5808     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5809     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5810     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5811
5812     state = 0xdeadbee;
5813     action = 0xdeadbee;
5814     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5815     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5816     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5817     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5818
5819     state = 0xdeadbee;
5820     action = 0xdeadbee;
5821     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5822     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5823     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5824     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5825
5826     state = 0xdeadbee;
5827     action = 0xdeadbee;
5828     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5829     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5830     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5831     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5832
5833     state = 0xdeadbee;
5834     action = 0xdeadbee;
5835     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5836     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5837     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5838     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5839
5840     state = 0xdeadbee;
5841     action = 0xdeadbee;
5842     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5843     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5844     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5845     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5846
5847     state = 0xdeadbee;
5848     action = 0xdeadbee;
5849     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5850     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5851     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5852     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5853
5854     state = 0xdeadbee;
5855     action = 0xdeadbee;
5856     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5857     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5858     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5859     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5860
5861     state = 0xdeadbee;
5862     action = 0xdeadbee;
5863     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5864     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5865     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5866     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5867
5868     state = 0xdeadbee;
5869     action = 0xdeadbee;
5870     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5871     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5872     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5873     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5874
5875     state = 0xdeadbee;
5876     action = 0xdeadbee;
5877     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5878     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5879     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5880     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5881
5882     state = 0xdeadbee;
5883     action = 0xdeadbee;
5884     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5885     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5886     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5887     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5888
5889     state = 0xdeadbee;
5890     action = 0xdeadbee;
5891     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5892     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5893     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5894     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5895
5896     state = 0xdeadbee;
5897     action = 0xdeadbee;
5898     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5899     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5900     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5901     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5902
5903     state = 0xdeadbee;
5904     action = 0xdeadbee;
5905     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5906     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5907     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5908     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5909
5910     state = 0xdeadbee;
5911     action = 0xdeadbee;
5912     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5913     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5914     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5915     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5916
5917     state = 0xdeadbee;
5918     action = 0xdeadbee;
5919     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5920     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5921     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5922     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5923
5924     state = 0xdeadbee;
5925     action = 0xdeadbee;
5926     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5927     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5928     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5929     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5930
5931     state = 0xdeadbee;
5932     action = 0xdeadbee;
5933     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5934     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5935     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5936     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5937
5938     state = 0xdeadbee;
5939     action = 0xdeadbee;
5940     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5941     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5942     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5943     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5944
5945     state = 0xdeadbee;
5946     action = 0xdeadbee;
5947     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5948     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5949     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5950     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5951
5952     state = 0xdeadbee;
5953     action = 0xdeadbee;
5954     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5955     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5956     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5957     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5958
5959     r = MsiDoAction( hpkg, "FileCost");
5960     ok( r == ERROR_SUCCESS, "file cost failed\n");
5961
5962     state = 0xdeadbee;
5963     action = 0xdeadbee;
5964     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
5991     action = 0xdeadbee;
5992     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5993     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5994     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5995     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5996
5997     state = 0xdeadbee;
5998     action = 0xdeadbee;
5999     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6000     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6001     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6002     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6003
6004     state = 0xdeadbee;
6005     action = 0xdeadbee;
6006     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6007     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6008     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6009     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6010
6011     state = 0xdeadbee;
6012     action = 0xdeadbee;
6013     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6014     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6015     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6016     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6017
6018     state = 0xdeadbee;
6019     action = 0xdeadbee;
6020     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6021     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6022     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6023     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6024
6025     state = 0xdeadbee;
6026     action = 0xdeadbee;
6027     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6028     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6029     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6030     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6031
6032     state = 0xdeadbee;
6033     action = 0xdeadbee;
6034     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6035     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6036     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6037     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6038
6039     state = 0xdeadbee;
6040     action = 0xdeadbee;
6041     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6042     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6043     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6044     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6045
6046     state = 0xdeadbee;
6047     action = 0xdeadbee;
6048     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6049     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6050     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6051     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6052
6053     state = 0xdeadbee;
6054     action = 0xdeadbee;
6055     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6056     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6057     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6058     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6059
6060     state = 0xdeadbee;
6061     action = 0xdeadbee;
6062     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6063     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6064     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6065     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6066
6067     state = 0xdeadbee;
6068     action = 0xdeadbee;
6069     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6070     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6071     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6072     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6073
6074     state = 0xdeadbee;
6075     action = 0xdeadbee;
6076     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6080
6081     state = 0xdeadbee;
6082     action = 0xdeadbee;
6083     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6087
6088     state = 0xdeadbee;
6089     action = 0xdeadbee;
6090     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6094
6095     state = 0xdeadbee;
6096     action = 0xdeadbee;
6097     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6101
6102     state = 0xdeadbee;
6103     action = 0xdeadbee;
6104     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6108
6109     state = 0xdeadbee;
6110     action = 0xdeadbee;
6111     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6115
6116     state = 0xdeadbee;
6117     action = 0xdeadbee;
6118     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6122
6123     state = 0xdeadbee;
6124     action = 0xdeadbee;
6125     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6126     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6127     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6128     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6129
6130     state = 0xdeadbee;
6131     action = 0xdeadbee;
6132     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6134     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6135     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6136
6137     state = 0xdeadbee;
6138     action = 0xdeadbee;
6139     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6140     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6141     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6142     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6143
6144     state = 0xdeadbee;
6145     action = 0xdeadbee;
6146     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6147     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6148     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6149     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6150
6151     state = 0xdeadbee;
6152     action = 0xdeadbee;
6153     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6154     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6155     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6156     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6157
6158     state = 0xdeadbee;
6159     action = 0xdeadbee;
6160     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6164
6165     state = 0xdeadbee;
6166     action = 0xdeadbee;
6167     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6171
6172     state = 0xdeadbee;
6173     action = 0xdeadbee;
6174     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6176     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6177     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6178
6179     r = MsiDoAction( hpkg, "CostFinalize");
6180     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6181
6182     state = 0xdeadbee;
6183     action = 0xdeadbee;
6184     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6185     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6186     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6187     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6188
6189     state = 0xdeadbee;
6190     action = 0xdeadbee;
6191     r = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &state, &action);
6199     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6200     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6201     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6202
6203     state = 0xdeadbee;
6204     action = 0xdeadbee;
6205     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6206     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6207     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6208     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6209
6210     state = 0xdeadbee;
6211     action = 0xdeadbee;
6212     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6213     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6214     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6215     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6216
6217     state = 0xdeadbee;
6218     action = 0xdeadbee;
6219     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6220     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6221     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6222     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6223
6224     state = 0xdeadbee;
6225     action = 0xdeadbee;
6226     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6227     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6228     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6229     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6230
6231     state = 0xdeadbee;
6232     action = 0xdeadbee;
6233     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6234     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6235     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6236     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6237
6238     state = 0xdeadbee;
6239     action = 0xdeadbee;
6240     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6241     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6242     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6243     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6244
6245     state = 0xdeadbee;
6246     action = 0xdeadbee;
6247     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6248     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6249     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6250     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6251
6252     state = 0xdeadbee;
6253     action = 0xdeadbee;
6254     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6255     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6256     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6257     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6258
6259     state = 0xdeadbee;
6260     action = 0xdeadbee;
6261     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6262     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6263     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6264     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6265
6266     state = 0xdeadbee;
6267     action = 0xdeadbee;
6268     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6269     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6270     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6271     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6272
6273     state = 0xdeadbee;
6274     action = 0xdeadbee;
6275     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6276     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6277     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6278     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6279
6280     state = 0xdeadbee;
6281     action = 0xdeadbee;
6282     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6283     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6284     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6285     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6286
6287     state = 0xdeadbee;
6288     action = 0xdeadbee;
6289     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6290     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6291     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6292     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6293
6294     state = 0xdeadbee;
6295     action = 0xdeadbee;
6296     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6297     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6298     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6299     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6300
6301     state = 0xdeadbee;
6302     action = 0xdeadbee;
6303     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6304     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6305     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6306     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6307
6308     state = 0xdeadbee;
6309     action = 0xdeadbee;
6310     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6312     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6313     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6314
6315     state = 0xdeadbee;
6316     action = 0xdeadbee;
6317     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6319     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6320     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6321
6322     state = 0xdeadbee;
6323     action = 0xdeadbee;
6324     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6326     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6327     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6328
6329     state = 0xdeadbee;
6330     action = 0xdeadbee;
6331     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6333     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6334     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6335
6336     state = 0xdeadbee;
6337     action = 0xdeadbee;
6338     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6340     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6341     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6342
6343     state = 0xdeadbee;
6344     action = 0xdeadbee;
6345     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6347     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6348     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6349
6350     state = 0xdeadbee;
6351     action = 0xdeadbee;
6352     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6354     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6355     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6356
6357     state = 0xdeadbee;
6358     action = 0xdeadbee;
6359     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6361     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6362     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6363
6364     state = 0xdeadbee;
6365     action = 0xdeadbee;
6366     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6368     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6369     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6370
6371     state = 0xdeadbee;
6372     action = 0xdeadbee;
6373     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6375     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6376     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6377
6378     state = 0xdeadbee;
6379     action = 0xdeadbee;
6380     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6382     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6383     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6384
6385     state = 0xdeadbee;
6386     action = 0xdeadbee;
6387     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6388     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6389     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6390     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6391
6392     state = 0xdeadbee;
6393     action = 0xdeadbee;
6394     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6396     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6397     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6398
6399     MsiCloseHandle(hpkg);
6400
6401     /* reinstall the product */
6402     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6404
6405     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6406     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6407
6408     /* this property must not be in the saved msi file */
6409     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6410     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6411
6412     r = package_from_db( hdb, &hpkg );
6413     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6414
6415     state = 0xdeadbee;
6416     action = 0xdeadbee;
6417     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6418     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "two", &state, &action);
6425     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "three", &state, &action);
6432     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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 = MsiGetFeatureState(hpkg, "four", &state, &action);
6439     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, 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     state = 0xdeadbee;
6444     action = 0xdeadbee;
6445     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6446     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6447     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6448     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6449
6450     state = 0xdeadbee;
6451     action = 0xdeadbee;
6452     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6453     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6454     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6455     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6456
6457     state = 0xdeadbee;
6458     action = 0xdeadbee;
6459     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6460     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6461     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6462     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6463
6464     state = 0xdeadbee;
6465     action = 0xdeadbee;
6466     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6467     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6468     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6469     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6470
6471     state = 0xdeadbee;
6472     action = 0xdeadbee;
6473     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6474     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6475     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6476     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6477
6478     state = 0xdeadbee;
6479     action = 0xdeadbee;
6480     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6481     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6482     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6483     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6484
6485     state = 0xdeadbee;
6486     action = 0xdeadbee;
6487     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6488     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6489     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6490     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6491
6492     state = 0xdeadbee;
6493     action = 0xdeadbee;
6494     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6495     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6496     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6497     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6498
6499     state = 0xdeadbee;
6500     action = 0xdeadbee;
6501     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6502     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6503     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6504     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6505
6506     state = 0xdeadbee;
6507     action = 0xdeadbee;
6508     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6509     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6510     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6511     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6512
6513     state = 0xdeadbee;
6514     action = 0xdeadbee;
6515     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6516     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6517     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6518     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6519
6520     state = 0xdeadbee;
6521     action = 0xdeadbee;
6522     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6523     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6524     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6525     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6526
6527     state = 0xdeadbee;
6528     action = 0xdeadbee;
6529     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6530     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6531     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6532     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6533
6534     state = 0xdeadbee;
6535     action = 0xdeadbee;
6536     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6537     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6538     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6539     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6540
6541     state = 0xdeadbee;
6542     action = 0xdeadbee;
6543     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6544     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6545     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6546     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6547
6548     state = 0xdeadbee;
6549     action = 0xdeadbee;
6550     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6551     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6552     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6553     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6554
6555     state = 0xdeadbee;
6556     action = 0xdeadbee;
6557     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6558     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6559     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6560     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6561
6562     state = 0xdeadbee;
6563     action = 0xdeadbee;
6564     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6565     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6566     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6567     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6568
6569     state = 0xdeadbee;
6570     action = 0xdeadbee;
6571     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6572     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6573     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6574     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6575
6576     state = 0xdeadbee;
6577     action = 0xdeadbee;
6578     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6579     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6580     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6581     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6582
6583     state = 0xdeadbee;
6584     action = 0xdeadbee;
6585     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6586     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6587     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6588     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6589
6590     state = 0xdeadbee;
6591     action = 0xdeadbee;
6592     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6593     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6594     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6595     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6596
6597     state = 0xdeadbee;
6598     action = 0xdeadbee;
6599     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6600     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6601     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6602     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6603
6604     state = 0xdeadbee;
6605     action = 0xdeadbee;
6606     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6607     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6608     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6609     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6610
6611     state = 0xdeadbee;
6612     action = 0xdeadbee;
6613     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6614     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6615     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6616     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6617
6618     state = 0xdeadbee;
6619     action = 0xdeadbee;
6620     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6621     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6622     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6623     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6624
6625     state = 0xdeadbee;
6626     action = 0xdeadbee;
6627     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6628     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6629     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6630     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6631
6632     r = MsiDoAction( hpkg, "CostInitialize");
6633     ok( r == ERROR_SUCCESS, "cost init failed\n");
6634
6635     state = 0xdeadbee;
6636     action = 0xdeadbee;
6637     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
6664     action = 0xdeadbee;
6665     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6667     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6668     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6669
6670     state = 0xdeadbee;
6671     action = 0xdeadbee;
6672     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6674     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6675     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6676
6677     state = 0xdeadbee;
6678     action = 0xdeadbee;
6679     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6681     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6682     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6683
6684     state = 0xdeadbee;
6685     action = 0xdeadbee;
6686     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6688     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6689     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6690
6691     state = 0xdeadbee;
6692     action = 0xdeadbee;
6693     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6695     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6696     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6697
6698     state = 0xdeadbee;
6699     action = 0xdeadbee;
6700     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6701     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6702     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6703     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6704
6705     state = 0xdeadbee;
6706     action = 0xdeadbee;
6707     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6708     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6709     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6710     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6711
6712     state = 0xdeadbee;
6713     action = 0xdeadbee;
6714     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6715     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6716     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6717     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6718
6719     state = 0xdeadbee;
6720     action = 0xdeadbee;
6721     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6722     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6723     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6724     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6725
6726     state = 0xdeadbee;
6727     action = 0xdeadbee;
6728     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6729     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6730     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6731     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6732
6733     state = 0xdeadbee;
6734     action = 0xdeadbee;
6735     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6736     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6737     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6738     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6739
6740     state = 0xdeadbee;
6741     action = 0xdeadbee;
6742     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6743     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6744     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6745     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6746
6747     state = 0xdeadbee;
6748     action = 0xdeadbee;
6749     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6750     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6751     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6752     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6753
6754     state = 0xdeadbee;
6755     action = 0xdeadbee;
6756     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6757     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6758     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6759     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6760
6761     state = 0xdeadbee;
6762     action = 0xdeadbee;
6763     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6764     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6765     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6766     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6767
6768     state = 0xdeadbee;
6769     action = 0xdeadbee;
6770     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6771     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6772     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6773     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6774
6775     state = 0xdeadbee;
6776     action = 0xdeadbee;
6777     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6778     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6779     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6780     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6781
6782     state = 0xdeadbee;
6783     action = 0xdeadbee;
6784     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6785     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6786     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6787     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6788
6789     state = 0xdeadbee;
6790     action = 0xdeadbee;
6791     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6792     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6793     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6794     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6795
6796     state = 0xdeadbee;
6797     action = 0xdeadbee;
6798     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6799     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6800     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6801     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6802
6803     state = 0xdeadbee;
6804     action = 0xdeadbee;
6805     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6806     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6807     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6808     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6809
6810     state = 0xdeadbee;
6811     action = 0xdeadbee;
6812     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6813     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6814     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6815     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6816
6817     state = 0xdeadbee;
6818     action = 0xdeadbee;
6819     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6820     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6821     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6822     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6823
6824     state = 0xdeadbee;
6825     action = 0xdeadbee;
6826     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6827     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6828     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6829     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6830
6831     state = 0xdeadbee;
6832     action = 0xdeadbee;
6833     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6834     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6835     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6836     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6837
6838     state = 0xdeadbee;
6839     action = 0xdeadbee;
6840     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6841     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6842     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6843     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6844
6845     state = 0xdeadbee;
6846     action = 0xdeadbee;
6847     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6848     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6849     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6850     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6851
6852     r = MsiDoAction( hpkg, "FileCost");
6853     ok( r == ERROR_SUCCESS, "file cost failed\n");
6854
6855     state = 0xdeadbee;
6856     action = 0xdeadbee;
6857     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
6884     action = 0xdeadbee;
6885     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6886     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6887     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6888     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6889
6890     state = 0xdeadbee;
6891     action = 0xdeadbee;
6892     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6893     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6894     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6895     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6896
6897     state = 0xdeadbee;
6898     action = 0xdeadbee;
6899     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6900     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6901     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6902     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6903
6904     state = 0xdeadbee;
6905     action = 0xdeadbee;
6906     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6907     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6908     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6909     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6910
6911     state = 0xdeadbee;
6912     action = 0xdeadbee;
6913     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6914     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6915     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6916     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6917
6918     state = 0xdeadbee;
6919     action = 0xdeadbee;
6920     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6921     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6922     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6923     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6924
6925     state = 0xdeadbee;
6926     action = 0xdeadbee;
6927     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6928     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6929     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6930     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6931
6932     state = 0xdeadbee;
6933     action = 0xdeadbee;
6934     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6935     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6936     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6937     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6938
6939     state = 0xdeadbee;
6940     action = 0xdeadbee;
6941     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6942     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6943     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6944     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6945
6946     state = 0xdeadbee;
6947     action = 0xdeadbee;
6948     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6949     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6950     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6951     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6952
6953     state = 0xdeadbee;
6954     action = 0xdeadbee;
6955     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6956     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6957     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6958     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6959
6960     state = 0xdeadbee;
6961     action = 0xdeadbee;
6962     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6963     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6964     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6965     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6966
6967     state = 0xdeadbee;
6968     action = 0xdeadbee;
6969     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6970     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6971     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6972     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6973
6974     state = 0xdeadbee;
6975     action = 0xdeadbee;
6976     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6977     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6978     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6979     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6980
6981     state = 0xdeadbee;
6982     action = 0xdeadbee;
6983     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6984     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6985     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6986     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6987
6988     state = 0xdeadbee;
6989     action = 0xdeadbee;
6990     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6991     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6992     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6993     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6994
6995     state = 0xdeadbee;
6996     action = 0xdeadbee;
6997     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6998     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6999     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7000     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7001
7002     state = 0xdeadbee;
7003     action = 0xdeadbee;
7004     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7005     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7006     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7007     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7008
7009     state = 0xdeadbee;
7010     action = 0xdeadbee;
7011     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7012     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7013     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7014     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7015
7016     state = 0xdeadbee;
7017     action = 0xdeadbee;
7018     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7019     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7020     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7021     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7022
7023     state = 0xdeadbee;
7024     action = 0xdeadbee;
7025     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7026     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7027     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7028     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7029
7030     state = 0xdeadbee;
7031     action = 0xdeadbee;
7032     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7034     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7035     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7036
7037     state = 0xdeadbee;
7038     action = 0xdeadbee;
7039     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7040     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7041     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7042     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7043
7044     state = 0xdeadbee;
7045     action = 0xdeadbee;
7046     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7047     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7048     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7049     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7050
7051     state = 0xdeadbee;
7052     action = 0xdeadbee;
7053     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7055     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7056     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7057
7058     state = 0xdeadbee;
7059     action = 0xdeadbee;
7060     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7061     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7062     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7063     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7064
7065     state = 0xdeadbee;
7066     action = 0xdeadbee;
7067     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7068     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7069     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7070     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7071
7072     r = MsiDoAction( hpkg, "CostFinalize");
7073     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
7074
7075     state = 0xdeadbee;
7076     action = 0xdeadbee;
7077     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7079     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7080     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7081
7082     state = 0xdeadbee;
7083     action = 0xdeadbee;
7084     r = MsiGetFeatureState(hpkg, "two", &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( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7088
7089     state = 0xdeadbee;
7090     action = 0xdeadbee;
7091     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7093     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7094     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7095
7096     state = 0xdeadbee;
7097     action = 0xdeadbee;
7098     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7100     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7101     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7102
7103     state = 0xdeadbee;
7104     action = 0xdeadbee;
7105     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7107     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7108     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7109
7110     state = 0xdeadbee;
7111     action = 0xdeadbee;
7112     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7114     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7115     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7116
7117     state = 0xdeadbee;
7118     action = 0xdeadbee;
7119     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7121     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7122     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7123
7124     state = 0xdeadbee;
7125     action = 0xdeadbee;
7126     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7128     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7129     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7130
7131     state = 0xdeadbee;
7132     action = 0xdeadbee;
7133     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7135     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7136     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7137
7138     state = 0xdeadbee;
7139     action = 0xdeadbee;
7140     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7142     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7143     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7144
7145     state = 0xdeadbee;
7146     action = 0xdeadbee;
7147     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7149     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7150     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7151
7152     state = 0xdeadbee;
7153     action = 0xdeadbee;
7154     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7156     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7157     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7158
7159     state = 0xdeadbee;
7160     action = 0xdeadbee;
7161     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7163     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7164     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7165
7166     state = 0xdeadbee;
7167     action = 0xdeadbee;
7168     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7170     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7171     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7172
7173     state = 0xdeadbee;
7174     action = 0xdeadbee;
7175     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7177     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7178     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7179
7180     state = 0xdeadbee;
7181     action = 0xdeadbee;
7182     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7184     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7185     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7186
7187     state = 0xdeadbee;
7188     action = 0xdeadbee;
7189     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7191     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7192     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7193
7194     state = 0xdeadbee;
7195     action = 0xdeadbee;
7196     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7197     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7198     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7199     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7200
7201     state = 0xdeadbee;
7202     action = 0xdeadbee;
7203     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7204     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7205     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7206     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7207
7208     state = 0xdeadbee;
7209     action = 0xdeadbee;
7210     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7211     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7212     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7213     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7214
7215     state = 0xdeadbee;
7216     action = 0xdeadbee;
7217     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7218     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7219     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7220     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7221
7222     state = 0xdeadbee;
7223     action = 0xdeadbee;
7224     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7225     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7226     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7227     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7228
7229     state = 0xdeadbee;
7230     action = 0xdeadbee;
7231     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7232     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7233     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7234     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7235
7236     state = 0xdeadbee;
7237     action = 0xdeadbee;
7238     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7239     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7240     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7241     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7242
7243     state = 0xdeadbee;
7244     action = 0xdeadbee;
7245     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7246     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7247     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7248     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7249
7250     state = 0xdeadbee;
7251     action = 0xdeadbee;
7252     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7253     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7254     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7255     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7256
7257     state = 0xdeadbee;
7258     action = 0xdeadbee;
7259     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7260     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7261     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7262     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7263
7264     state = 0xdeadbee;
7265     action = 0xdeadbee;
7266     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7267     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7268     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7269     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7270
7271     state = 0xdeadbee;
7272     action = 0xdeadbee;
7273     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7274     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7275     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7276     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7277
7278     state = 0xdeadbee;
7279     action = 0xdeadbee;
7280     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7281     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7282     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7283     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7284
7285     state = 0xdeadbee;
7286     action = 0xdeadbee;
7287     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7288     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7289     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7290     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7291
7292     MsiCloseHandle(hpkg);
7293
7294     /* uninstall the product */
7295     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7296     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7297
7298     DeleteFileA(msifile);
7299     DeleteFileA(msifile2);
7300     DeleteFileA(msifile3);
7301     DeleteFileA(msifile4);
7302 }
7303
7304 static void test_getproperty(void)
7305 {
7306     MSIHANDLE hPackage = 0;
7307     char prop[100];
7308     static CHAR empty[] = "";
7309     DWORD size;
7310     UINT r;
7311
7312     r = package_from_db(create_package_db(), &hPackage);
7313     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7314     {
7315         skip("Not enough rights to perform tests\n");
7316         DeleteFile(msifile);
7317         return;
7318     }
7319     ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
7320
7321     /* set the property */
7322     r = MsiSetProperty(hPackage, "Name", "Value");
7323     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7324
7325     /* retrieve the size, NULL pointer */
7326     size = 0;
7327     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7328     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7329     ok( size == 5, "Expected 5, got %d\n", size);
7330
7331     /* retrieve the size, empty string */
7332     size = 0;
7333     r = MsiGetProperty(hPackage, "Name", empty, &size);
7334     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7335     ok( size == 5, "Expected 5, got %d\n", size);
7336
7337     /* don't change size */
7338     r = MsiGetProperty(hPackage, "Name", prop, &size);
7339     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7340     ok( size == 5, "Expected 5, got %d\n", size);
7341     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7342
7343     /* increase the size by 1 */
7344     size++;
7345     r = MsiGetProperty(hPackage, "Name", prop, &size);
7346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7347     ok( size == 5, "Expected 5, got %d\n", size);
7348     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7349
7350     r = MsiCloseHandle( hPackage);
7351     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7352     DeleteFile(msifile);
7353 }
7354
7355 static void test_removefiles(void)
7356 {
7357     MSIHANDLE hpkg;
7358     UINT r;
7359     MSIHANDLE hdb;
7360
7361     hdb = create_package_db();
7362     ok ( hdb, "failed to create package database\n" );
7363
7364     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7365     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7366
7367     r = create_feature_table( hdb );
7368     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7369
7370     r = create_component_table( hdb );
7371     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7372
7373     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7374     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7375
7376     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7377     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7378
7379     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7380     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7381
7382     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7383     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7384
7385     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7386     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7387
7388     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7389     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7390
7391     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7392     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7393
7394     r = create_feature_components_table( hdb );
7395     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7396
7397     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7398     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7399
7400     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7401     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7402
7403     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7404     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7405
7406     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7407     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7408
7409     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7410     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7411
7412     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7413     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7414
7415     r = create_file_table( hdb );
7416     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7417
7418     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7419     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7420
7421     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7422     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7423
7424     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7425     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7426
7427     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7428     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7429
7430     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7431     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7432
7433     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7434     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7435
7436     r = create_remove_file_table( hdb );
7437     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7438
7439     r = package_from_db( hdb, &hpkg );
7440     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7441     {
7442         skip("Not enough rights to perform tests\n");
7443         DeleteFile(msifile);
7444         return;
7445     }
7446     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7447
7448     MsiCloseHandle( hdb );
7449
7450     create_test_file( "hydrogen.txt" );
7451     create_test_file( "helium.txt" );
7452     create_test_file( "lithium.txt" );
7453     create_test_file( "beryllium.txt" );
7454     create_test_file( "boron.txt" );
7455     create_test_file( "carbon.txt" );
7456
7457     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7458     ok( r == ERROR_SUCCESS, "set property failed\n");
7459
7460     r = MsiDoAction( hpkg, "CostInitialize");
7461     ok( r == ERROR_SUCCESS, "cost init failed\n");
7462
7463     r = MsiDoAction( hpkg, "FileCost");
7464     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7465
7466     r = MsiDoAction( hpkg, "CostFinalize");
7467     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7468
7469     r = MsiDoAction( hpkg, "InstallValidate");
7470     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7471
7472     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7473     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7474
7475     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7476     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7477
7478     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7479     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7480
7481     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7482     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7483
7484     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7485     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7486
7487     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7488     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7489
7490     r = MsiDoAction( hpkg, "RemoveFiles");
7491     ok( r == ERROR_SUCCESS, "remove files failed\n");
7492
7493     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7494     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7495     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7496     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7497     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7498     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7499
7500     MsiCloseHandle( hpkg );
7501     DeleteFileA(msifile);
7502 }
7503
7504 static void test_appsearch(void)
7505 {
7506     MSIHANDLE hpkg;
7507     UINT r;
7508     MSIHANDLE hdb;
7509     CHAR prop[MAX_PATH];
7510     DWORD size;
7511
7512     hdb = create_package_db();
7513     ok ( hdb, "failed to create package database\n" );
7514
7515     r = create_appsearch_table( hdb );
7516     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7517
7518     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7519     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7520
7521     r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
7522     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7523
7524     r = create_reglocator_table( hdb );
7525     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7526
7527     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
7528     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7529
7530     r = create_drlocator_table( hdb );
7531     ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
7532
7533     r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
7534     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7535
7536     r = create_signature_table( hdb );
7537     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7538
7539     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7540     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7541
7542     r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
7543     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7544
7545     r = package_from_db( hdb, &hpkg );
7546     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7547     {
7548         skip("Not enough rights to perform tests\n");
7549         DeleteFile(msifile);
7550         return;
7551     }
7552     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7553     MsiCloseHandle( hdb );
7554     if (r != ERROR_SUCCESS)
7555         goto done;
7556
7557     r = MsiDoAction( hpkg, "AppSearch" );
7558     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7559
7560     size = sizeof(prop);
7561     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7562     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7563     todo_wine
7564     {
7565         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7566     }
7567
7568     size = sizeof(prop);
7569     r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
7570     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7571
7572 done:
7573     MsiCloseHandle( hpkg );
7574     DeleteFileA(msifile);
7575 }
7576
7577 static void test_appsearch_complocator(void)
7578 {
7579     MSIHANDLE hpkg, hdb;
7580     CHAR path[MAX_PATH];
7581     CHAR prop[MAX_PATH];
7582     LPSTR usersid;
7583     DWORD size;
7584     UINT r;
7585
7586     if (!get_user_sid(&usersid))
7587         return;
7588
7589     if (is_process_limited())
7590     {
7591         skip("process is limited\n");
7592         return;
7593     }
7594
7595     create_test_file("FileName1");
7596     create_test_file("FileName4");
7597     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
7598                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
7599
7600     create_test_file("FileName2");
7601     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
7602                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
7603
7604     create_test_file("FileName3");
7605     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
7606                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
7607
7608     create_test_file("FileName5");
7609     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
7610                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
7611
7612     create_test_file("FileName6");
7613     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
7614                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
7615
7616     create_test_file("FileName7");
7617     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
7618                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
7619
7620     /* dir is FALSE, but we're pretending it's a directory */
7621     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
7622                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
7623
7624     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7625     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
7626                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
7627
7628     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7629     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
7630                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
7631
7632     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7633     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
7634                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
7635
7636     hdb = create_package_db();
7637     ok(hdb, "Expected a valid database handle\n");
7638
7639     r = create_appsearch_table(hdb);
7640     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7641
7642     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7643     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7644
7645     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
7646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7647
7648     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
7649     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7650
7651     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
7652     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7653
7654     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
7655     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7656
7657     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
7658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7659
7660     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
7661     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7662
7663     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
7664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7665
7666     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
7667     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7668
7669     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
7670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7671
7672     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
7673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7674
7675     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
7676     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7677
7678     r = create_complocator_table(hdb);
7679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7680
7681     /* published component, machine, file, signature, misdbLocatorTypeFile */
7682     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
7683     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7684
7685     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
7686     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
7687     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7688
7689     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
7690     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
7691     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7692
7693     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
7694     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
7695     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7696
7697     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
7698     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
7699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7700
7701     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
7702     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
7703     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7704
7705     /* published component, machine, file, no signature, misdbLocatorTypeFile */
7706     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
7707     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7708
7709     /* unpublished component, no signature, misdbLocatorTypeDir */
7710     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
7711     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7712
7713     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
7714     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
7715     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7716
7717     /* published component, signature w/ ver, misdbLocatorTypeFile */
7718     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
7719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7720
7721     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
7722     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
7723     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7724
7725     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
7726     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
7727     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7728
7729     r = create_signature_table(hdb);
7730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7731
7732     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
7733     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7734
7735     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
7736     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7737
7738     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
7739     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7740
7741     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
7742     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7743
7744     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
7745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7746
7747     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7749
7750     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7751     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7752
7753     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7755
7756     r = package_from_db(hdb, &hpkg);
7757     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7758     {
7759         skip("Not enough rights to perform tests\n");
7760         goto error;
7761     }
7762     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
7763
7764     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
7765     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7766
7767     r = MsiDoAction(hpkg, "AppSearch");
7768     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7769
7770     size = MAX_PATH;
7771     sprintf(path, "%s\\FileName1", CURR_DIR);
7772     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
7773     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7774     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7775
7776     size = MAX_PATH;
7777     sprintf(path, "%s\\FileName2", CURR_DIR);
7778     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
7779     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7780     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7781
7782     size = MAX_PATH;
7783     sprintf(path, "%s\\FileName3", CURR_DIR);
7784     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
7785     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7786     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7787
7788     size = MAX_PATH;
7789     sprintf(path, "%s\\FileName4", CURR_DIR);
7790     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
7791     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7792     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7793
7794     size = MAX_PATH;
7795     sprintf(path, "%s\\FileName5", CURR_DIR);
7796     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
7797     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7798     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7799
7800     size = MAX_PATH;
7801     sprintf(path, "%s\\", CURR_DIR);
7802     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
7803     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7804     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7805
7806     size = MAX_PATH;
7807     sprintf(path, "%s\\", CURR_DIR);
7808     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
7809     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7810     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7811
7812     size = MAX_PATH;
7813     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
7814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7815     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
7816
7817     size = MAX_PATH;
7818     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
7819     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7820     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7821
7822     size = MAX_PATH;
7823     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
7824     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
7825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7826     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7827
7828     size = MAX_PATH;
7829     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
7830     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7831     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7832
7833     size = MAX_PATH;
7834     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
7835     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
7836     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7837     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7838
7839     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
7840                           MSIINSTALLCONTEXT_MACHINE, NULL);
7841     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
7842                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
7843     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
7844                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
7845     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
7846                           MSIINSTALLCONTEXT_MACHINE, NULL);
7847     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
7848                           MSIINSTALLCONTEXT_MACHINE, NULL);
7849     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
7850                           MSIINSTALLCONTEXT_MACHINE, NULL);
7851     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
7852                           MSIINSTALLCONTEXT_MACHINE, NULL);
7853     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
7854                           MSIINSTALLCONTEXT_MACHINE, NULL);
7855     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
7856                           MSIINSTALLCONTEXT_MACHINE, NULL);
7857     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
7858                           MSIINSTALLCONTEXT_MACHINE, NULL);
7859
7860     MsiCloseHandle(hpkg);
7861
7862 error:
7863     DeleteFileA("FileName1");
7864     DeleteFileA("FileName2");
7865     DeleteFileA("FileName3");
7866     DeleteFileA("FileName4");
7867     DeleteFileA("FileName5");
7868     DeleteFileA("FileName6");
7869     DeleteFileA("FileName7");
7870     DeleteFileA("FileName8.dll");
7871     DeleteFileA("FileName9.dll");
7872     DeleteFileA("FileName10.dll");
7873     DeleteFileA(msifile);
7874     LocalFree(usersid);
7875 }
7876
7877 static void test_appsearch_reglocator(void)
7878 {
7879     MSIHANDLE hpkg, hdb;
7880     CHAR path[MAX_PATH], prop[MAX_PATH];
7881     DWORD binary[2], size, val;
7882     BOOL space, version;
7883     HKEY hklm, classes, hkcu, users;
7884     LPSTR pathdata, pathvar, ptr;
7885     LPCSTR str;
7886     LONG res;
7887     UINT r;
7888
7889     version = TRUE;
7890     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
7891         version = FALSE;
7892
7893     DeleteFileA("test.dll");
7894
7895     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
7896     if (res == ERROR_ACCESS_DENIED)
7897     {
7898         skip("Not enough rights to perform tests\n");
7899         return;
7900     }
7901     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7902
7903     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
7904                          (const BYTE *)"regszdata", 10);
7905     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7906
7907     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
7908     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7909
7910     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
7911                          (const BYTE *)"regszdata", 10);
7912     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7913
7914     users = 0;
7915     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
7916     ok(res == ERROR_SUCCESS ||
7917        broken(res == ERROR_INVALID_PARAMETER),
7918        "Expected ERROR_SUCCESS, got %d\n", res);
7919
7920     if (res == ERROR_SUCCESS)
7921     {
7922         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
7923                              (const BYTE *)"regszdata", 10);
7924         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7925     }
7926
7927     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
7928     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7929
7930     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
7931     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7932
7933     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
7934                          (const BYTE *)"regszdata", 10);
7935     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7936
7937     val = 42;
7938     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
7939                          (const BYTE *)&val, sizeof(DWORD));
7940     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7941
7942     val = -42;
7943     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
7944                          (const BYTE *)&val, sizeof(DWORD));
7945     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7946
7947     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
7948                          (const BYTE *)"%PATH%", 7);
7949     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7950
7951     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
7952                          (const BYTE *)"my%NOVAR%", 10);
7953     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7954
7955     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
7956                          (const BYTE *)"one\0two\0", 9);
7957     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7958
7959     binary[0] = 0x1234abcd;
7960     binary[1] = 0x567890ef;
7961     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
7962                          (const BYTE *)binary, sizeof(binary));
7963     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7964
7965     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
7966                          (const BYTE *)"#regszdata", 11);
7967     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7968
7969     create_test_file("FileName1");
7970     sprintf(path, "%s\\FileName1", CURR_DIR);
7971     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
7972                          (const BYTE *)path, lstrlenA(path) + 1);
7973     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7974
7975     sprintf(path, "%s\\FileName2", CURR_DIR);
7976     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
7977                          (const BYTE *)path, lstrlenA(path) + 1);
7978     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7979
7980     lstrcpyA(path, CURR_DIR);
7981     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
7982                          (const BYTE *)path, lstrlenA(path) + 1);
7983     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7984
7985     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
7986                          (const BYTE *)"", 1);
7987     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7988
7989     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7990     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
7991     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
7992                          (const BYTE *)path, lstrlenA(path) + 1);
7993     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7994
7995     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7996     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
7997     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
7998                          (const BYTE *)path, lstrlenA(path) + 1);
7999     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8000
8001     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8002     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8003     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
8004                          (const BYTE *)path, lstrlenA(path) + 1);
8005     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8006
8007     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
8008     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
8009                          (const BYTE *)path, lstrlenA(path) + 1);
8010
8011     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
8012     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
8013     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
8014                          (const BYTE *)path, lstrlenA(path) + 1);
8015
8016     hdb = create_package_db();
8017     ok(hdb, "Expected a valid database handle\n");
8018
8019     r = create_appsearch_table(hdb);
8020     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8021
8022     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8023     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8024
8025     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8026     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8027
8028     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8029     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8030
8031     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8032     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8033
8034     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8036
8037     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8039
8040     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8042
8043     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8045
8046     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8048
8049     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8050     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8051
8052     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8054
8055     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8056     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8057
8058     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8060
8061     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
8062     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8063
8064     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
8065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8066
8067     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
8068     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8069
8070     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
8071     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8072
8073     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
8074     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8075
8076     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
8077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8078
8079     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
8080     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8081
8082     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
8083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8084
8085     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
8086     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8087
8088     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
8089     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8090
8091     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
8092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8093
8094     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
8095     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8096
8097     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
8098     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8099
8100     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
8101     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8102
8103     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
8104     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8105
8106     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
8107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8108
8109     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
8110     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8111
8112     r = create_reglocator_table(hdb);
8113     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8114
8115     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
8116     str = "'NewSignature1', 2, 'Software\\Wine', 'Value1', 2";
8117     r = add_reglocator_entry(hdb, str);
8118     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8119
8120     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
8121     str = "'NewSignature2', 2, 'Software\\Wine', 'Value2', 2";
8122     r = add_reglocator_entry(hdb, str);
8123     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8124
8125     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
8126     str = "'NewSignature3', 2, 'Software\\Wine', 'Value3', 2";
8127     r = add_reglocator_entry(hdb, str);
8128     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8129
8130     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8131     str = "'NewSignature4', 2, 'Software\\Wine', 'Value4', 2";
8132     r = add_reglocator_entry(hdb, str);
8133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8134
8135     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8136     str = "'NewSignature5', 2, 'Software\\Wine', 'Value5', 2";
8137     r = add_reglocator_entry(hdb, str);
8138     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8139
8140     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
8141     str = "'NewSignature6', 2, 'Software\\Wine', 'Value6', 2";
8142     r = add_reglocator_entry(hdb, str);
8143     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8144
8145     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
8146     str = "'NewSignature7', 2, 'Software\\Wine', 'Value7', 2";
8147     r = add_reglocator_entry(hdb, str);
8148     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8149
8150     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
8151     str = "'NewSignature8', 2, 'Software\\Wine', 'Value8', 2";
8152     r = add_reglocator_entry(hdb, str);
8153     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8154
8155     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
8156     str = "'NewSignature9', 2, 'Software\\Wine', 'Value9', 1";
8157     r = add_reglocator_entry(hdb, str);
8158     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8159
8160     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
8161     str = "'NewSignature10', 2, 'Software\\Wine', 'Value10', 1";
8162     r = add_reglocator_entry(hdb, str);
8163     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8164
8165     /* HKLM, msidbLocatorTypeFileName, no signature */
8166     str = "'NewSignature11', 2, 'Software\\Wine', 'Value9', 1";
8167     r = add_reglocator_entry(hdb, str);
8168     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8169
8170     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
8171     str = "'NewSignature12', 2, 'Software\\Wine', 'Value9', 0";
8172     r = add_reglocator_entry(hdb, str);
8173     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8174
8175     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
8176     str = "'NewSignature13', 2, 'Software\\Wine', 'Value11', 0";
8177     r = add_reglocator_entry(hdb, str);
8178     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8179
8180     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
8181     str = "'NewSignature14', 2, 'Software\\Wine', 'Value9', 0";
8182     r = add_reglocator_entry(hdb, str);
8183     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8184
8185     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
8186     str = "'NewSignature15', 0, 'Software\\Wine', 'Value1', 2";
8187     r = add_reglocator_entry(hdb, str);
8188     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8189
8190     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
8191     str = "'NewSignature16', 1, 'Software\\Wine', 'Value1', 2";
8192     r = add_reglocator_entry(hdb, str);
8193     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8194
8195     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
8196     str = "'NewSignature17', 3, 'S-1-5-18\\Software\\Wine', 'Value1', 2";
8197     r = add_reglocator_entry(hdb, str);
8198     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8199
8200     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
8201     str = "'NewSignature18', 2, 'Software\\Wine', '', 2";
8202     r = add_reglocator_entry(hdb, str);
8203     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8204
8205     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
8206     str = "'NewSignature19', 2, 'Software\\IDontExist', '', 2";
8207     r = add_reglocator_entry(hdb, str);
8208     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8209
8210     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
8211     str = "'NewSignature20', 2, 'Software\\Wine', 'Value12', 2";
8212     r = add_reglocator_entry(hdb, str);
8213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8214
8215     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
8216     str = "'NewSignature21', 2, 'Software\\Wine', 'Value13', 1";
8217     r = add_reglocator_entry(hdb, str);
8218     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8219
8220     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
8221     str = "'NewSignature22', 2, 'Software\\Wine', 'Value14', 1";
8222     r = add_reglocator_entry(hdb, str);
8223     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8224
8225     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
8226     str = "'NewSignature23', 2, 'Software\\Wine', 'Value15', 1";
8227     r = add_reglocator_entry(hdb, str);
8228     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8229
8230     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
8231     str = "'NewSignature24', 2, 'Software\\Wine', 'Value11', 1";
8232     r = add_reglocator_entry(hdb, str);
8233     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8234
8235     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
8236     str = "'NewSignature25', 2, 'Software\\Wine', 'Value10', 1";
8237     r = add_reglocator_entry(hdb, str);
8238     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8239
8240     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8241     str = "'NewSignature26', 2, 'Software\\Wine', 'Value11', 0";
8242     r = add_reglocator_entry(hdb, str);
8243     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8244
8245     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8246     str = "'NewSignature27', 2, 'Software\\Wine', 'Value10', 0";
8247     r = add_reglocator_entry(hdb, str);
8248     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8249
8250     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8251     str = "'NewSignature28', 2, 'Software\\Wine', 'Value10', 0";
8252     r = add_reglocator_entry(hdb, str);
8253     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8254
8255     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8256     str = "'NewSignature29', 2, 'Software\\Wine', 'Value16', 1";
8257     r = add_reglocator_entry(hdb, str);
8258     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8259
8260     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8261     str = "'NewSignature30', 2, 'Software\\Wine', 'Value17', 1";
8262     r = add_reglocator_entry(hdb, str);
8263     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8264
8265     r = create_signature_table(hdb);
8266     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8267
8268     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8269     r = add_signature_entry(hdb, str);
8270     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8271
8272     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8273     r = add_signature_entry(hdb, str);
8274     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8275
8276     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8277     r = add_signature_entry(hdb, str);
8278     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8279
8280     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8281     r = add_signature_entry(hdb, str);
8282     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8283
8284     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8285     r = add_signature_entry(hdb, str);
8286     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8287
8288     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8289     r = add_signature_entry(hdb, str);
8290     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8291
8292     ptr = strrchr(CURR_DIR, '\\') + 1;
8293     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8294     r = add_signature_entry(hdb, path);
8295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8296
8297     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8298     r = add_signature_entry(hdb, str);
8299     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8300
8301     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8302     r = add_signature_entry(hdb, str);
8303     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8304
8305     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8306     r = add_signature_entry(hdb, str);
8307     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8308
8309     r = package_from_db(hdb, &hpkg);
8310     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8311
8312     r = MsiDoAction(hpkg, "AppSearch");
8313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8314
8315     size = MAX_PATH;
8316     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8317     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8318     ok(!lstrcmpA(prop, "regszdata"),
8319        "Expected \"regszdata\", got \"%s\"\n", prop);
8320
8321     size = MAX_PATH;
8322     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8323     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8324     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8325
8326     size = MAX_PATH;
8327     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8328     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8329     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8330
8331     size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8332     if (size == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
8333     {
8334         /* Workaround for Win95 */
8335         CHAR tempbuf[1];
8336         size = ExpandEnvironmentStringsA("%PATH%", tempbuf, 0);
8337     }
8338     pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8339     ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8340
8341     size = 0;
8342     r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8343     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8344
8345     pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8346     r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8347     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8348     ok(!lstrcmpA(pathdata, pathvar),
8349        "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8350
8351     HeapFree(GetProcessHeap(), 0, pathvar);
8352     HeapFree(GetProcessHeap(), 0, pathdata);
8353
8354     size = MAX_PATH;
8355     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8356     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8357     ok(!lstrcmpA(prop,
8358        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8359
8360     size = MAX_PATH;
8361     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8362     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8363     todo_wine
8364     {
8365         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8366            "Expected \"\\0one\\0two\\0\\0\"\n");
8367     }
8368
8369     size = MAX_PATH;
8370     lstrcpyA(path, "#xCDAB3412EF907856");
8371     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8372     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8373     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8374
8375     size = MAX_PATH;
8376     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8377     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8378     ok(!lstrcmpA(prop, "##regszdata"),
8379        "Expected \"##regszdata\", got \"%s\"\n", prop);
8380
8381     size = MAX_PATH;
8382     sprintf(path, "%s\\FileName1", CURR_DIR);
8383     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8384     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8385     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8386
8387     size = MAX_PATH;
8388     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8389     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8390     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8391
8392     size = MAX_PATH;
8393     sprintf(path, "%s\\", CURR_DIR);
8394     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8395     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8396     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8397
8398     size = MAX_PATH;
8399     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8400     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8401     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8402
8403     size = MAX_PATH;
8404     sprintf(path, "%s\\", CURR_DIR);
8405     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
8406     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8407     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8408
8409     size = MAX_PATH;
8410     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
8411     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8412     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8413
8414     size = MAX_PATH;
8415     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8417     ok(!lstrcmpA(prop, "regszdata"),
8418        "Expected \"regszdata\", got \"%s\"\n", prop);
8419
8420     size = MAX_PATH;
8421     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8422     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8423     ok(!lstrcmpA(prop, "regszdata"),
8424        "Expected \"regszdata\", got \"%s\"\n", prop);
8425
8426     if (users)
8427     {
8428         size = MAX_PATH;
8429         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8430         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8431         ok(!lstrcmpA(prop, "regszdata"),
8432            "Expected \"regszdata\", got \"%s\"\n", prop);
8433     }
8434
8435     size = MAX_PATH;
8436     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8438     ok(!lstrcmpA(prop, "defvalue"),
8439        "Expected \"defvalue\", got \"%s\"\n", prop);
8440
8441     size = MAX_PATH;
8442     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8443     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8444     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8445
8446     size = MAX_PATH;
8447     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
8448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8449     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8450
8451     if (version)
8452     {
8453         size = MAX_PATH;
8454         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8455         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8456         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8457         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8458
8459         size = MAX_PATH;
8460         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8461         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8462         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8463
8464         size = MAX_PATH;
8465         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8466         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8467         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8468         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8469     }
8470
8471     size = MAX_PATH;
8472     lstrcpyA(path, CURR_DIR);
8473     ptr = strrchr(path, '\\') + 1;
8474     *ptr = '\0';
8475     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8476     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8477     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8478
8479     size = MAX_PATH;
8480     sprintf(path, "%s\\", CURR_DIR);
8481     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8482     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8483     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8484
8485     size = MAX_PATH;
8486     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8487     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8488     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8489
8490     size = MAX_PATH;
8491     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8493     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8494
8495     size = MAX_PATH;
8496     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8497     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8498     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8499
8500     size = MAX_PATH;
8501     sprintf(path, "%s\\FileName1", CURR_DIR);
8502     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8503     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8504     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8505
8506     size = MAX_PATH;
8507     sprintf(path, "%s\\FileName1", CURR_DIR);
8508     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8509     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8510     if (space)
8511         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8512     else
8513         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8514
8515     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8516     RegDeleteValueA(hklm, "Value1");
8517     RegDeleteValueA(hklm, "Value2");
8518     RegDeleteValueA(hklm, "Value3");
8519     RegDeleteValueA(hklm, "Value4");
8520     RegDeleteValueA(hklm, "Value5");
8521     RegDeleteValueA(hklm, "Value6");
8522     RegDeleteValueA(hklm, "Value7");
8523     RegDeleteValueA(hklm, "Value8");
8524     RegDeleteValueA(hklm, "Value9");
8525     RegDeleteValueA(hklm, "Value10");
8526     RegDeleteValueA(hklm, "Value11");
8527     RegDeleteValueA(hklm, "Value12");
8528     RegDeleteValueA(hklm, "Value13");
8529     RegDeleteValueA(hklm, "Value14");
8530     RegDeleteValueA(hklm, "Value15");
8531     RegDeleteValueA(hklm, "Value16");
8532     RegDeleteValueA(hklm, "Value17");
8533     RegDeleteKey(hklm, "");
8534     RegCloseKey(hklm);
8535
8536     RegDeleteValueA(classes, "Value1");
8537     RegDeleteKeyA(classes, "");
8538     RegCloseKey(classes);
8539
8540     RegDeleteValueA(hkcu, "Value1");
8541     RegDeleteKeyA(hkcu, "");
8542     RegCloseKey(hkcu);
8543
8544     RegDeleteValueA(users, "Value1");
8545     RegDeleteKeyA(users, "");
8546     RegCloseKey(users);
8547
8548     DeleteFileA("FileName1");
8549     DeleteFileA("FileName3.dll");
8550     DeleteFileA("FileName4.dll");
8551     DeleteFileA("FileName5.dll");
8552     MsiCloseHandle(hpkg);
8553     DeleteFileA(msifile);
8554 }
8555
8556 static void delete_win_ini(LPCSTR file)
8557 {
8558     CHAR path[MAX_PATH];
8559
8560     GetWindowsDirectoryA(path, MAX_PATH);
8561     lstrcatA(path, "\\");
8562     lstrcatA(path, file);
8563
8564     DeleteFileA(path);
8565 }
8566
8567 static void test_appsearch_inilocator(void)
8568 {
8569     MSIHANDLE hpkg, hdb;
8570     CHAR path[MAX_PATH];
8571     CHAR prop[MAX_PATH];
8572     BOOL version;
8573     LPCSTR str;
8574     LPSTR ptr;
8575     DWORD size;
8576     UINT r;
8577
8578     version = TRUE;
8579     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8580         version = FALSE;
8581
8582     DeleteFileA("test.dll");
8583
8584     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
8585
8586     create_test_file("FileName1");
8587     sprintf(path, "%s\\FileName1", CURR_DIR);
8588     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
8589
8590     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
8591
8592     sprintf(path, "%s\\IDontExist", CURR_DIR);
8593     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
8594
8595     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8596     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8597     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
8598
8599     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8600     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8601     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
8602
8603     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8604     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8605     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
8606
8607     hdb = create_package_db();
8608     ok(hdb, "Expected a valid database handle\n");
8609
8610     r = create_appsearch_table(hdb);
8611     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8612
8613     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8614     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8615
8616     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8617     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8618
8619     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8620     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8621
8622     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8623     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8624
8625     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8626     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8627
8628     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8629     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8630
8631     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8632     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8633
8634     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8635     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8636
8637     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8638     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8639
8640     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8641     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8642
8643     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8644     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8645
8646     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8647     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8648
8649     r = create_inilocator_table(hdb);
8650     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8651
8652     /* msidbLocatorTypeRawValue, field 1 */
8653     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
8654     r = add_inilocator_entry(hdb, str);
8655     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8656
8657     /* msidbLocatorTypeRawValue, field 2 */
8658     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
8659     r = add_inilocator_entry(hdb, str);
8660     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8661
8662     /* msidbLocatorTypeRawValue, entire field */
8663     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
8664     r = add_inilocator_entry(hdb, str);
8665     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8666
8667     /* msidbLocatorTypeFile */
8668     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8669     r = add_inilocator_entry(hdb, str);
8670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8671
8672     /* msidbLocatorTypeDirectory, file */
8673     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
8674     r = add_inilocator_entry(hdb, str);
8675     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8676
8677     /* msidbLocatorTypeDirectory, directory */
8678     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
8679     r = add_inilocator_entry(hdb, str);
8680     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8681
8682     /* msidbLocatorTypeFile, file, no signature */
8683     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8684     r = add_inilocator_entry(hdb, str);
8685     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8686
8687     /* msidbLocatorTypeFile, dir, no signature */
8688     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
8689     r = add_inilocator_entry(hdb, str);
8690     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8691
8692     /* msidbLocatorTypeFile, file does not exist */
8693     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
8694     r = add_inilocator_entry(hdb, str);
8695     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8696
8697     /* msidbLocatorTypeFile, signature with version */
8698     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
8699     r = add_inilocator_entry(hdb, str);
8700     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8701
8702     /* msidbLocatorTypeFile, signature with version, ver > max */
8703     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
8704     r = add_inilocator_entry(hdb, str);
8705     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8706
8707     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
8708     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
8709     r = add_inilocator_entry(hdb, str);
8710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8711
8712     r = create_signature_table(hdb);
8713     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8714
8715     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
8716     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8717
8718     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
8719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8720
8721     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8722     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8723
8724     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8726
8727     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8728     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8729
8730     r = package_from_db(hdb, &hpkg);
8731     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8732     {
8733         skip("Not enough rights to perform tests\n");
8734         goto error;
8735     }
8736     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8737
8738     r = MsiDoAction(hpkg, "AppSearch");
8739     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8740
8741     size = MAX_PATH;
8742     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8743     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8744     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
8745
8746     size = MAX_PATH;
8747     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8749     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
8750
8751     size = MAX_PATH;
8752     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8753     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8754     ok(!lstrcmpA(prop, "keydata,field2"),
8755        "Expected \"keydata,field2\", got \"%s\"\n", prop);
8756
8757     size = MAX_PATH;
8758     sprintf(path, "%s\\FileName1", CURR_DIR);
8759     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8760     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8761     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8762
8763     size = MAX_PATH;
8764     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8765     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8766     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8767
8768     size = MAX_PATH;
8769     sprintf(path, "%s\\", CURR_DIR);
8770     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8772     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8773
8774     size = MAX_PATH;
8775     sprintf(path, "%s\\", CURR_DIR);
8776     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8777     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8778     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8779
8780     size = MAX_PATH;
8781     lstrcpyA(path, CURR_DIR);
8782     ptr = strrchr(path, '\\');
8783     *(ptr + 1) = '\0';
8784     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8785     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8786     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8787
8788     size = MAX_PATH;
8789     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8791     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8792
8793     if (version)
8794     {
8795         size = MAX_PATH;
8796         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8797         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8798         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8799         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8800
8801         size = MAX_PATH;
8802         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8803         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8804         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8805
8806         size = MAX_PATH;
8807         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8808         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8809         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8810         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8811     }
8812
8813     MsiCloseHandle(hpkg);
8814
8815 error:
8816     delete_win_ini("IniFile.ini");
8817     DeleteFileA("FileName1");
8818     DeleteFileA("FileName2.dll");
8819     DeleteFileA("FileName3.dll");
8820     DeleteFileA("FileName4.dll");
8821     DeleteFileA(msifile);
8822 }
8823
8824 /*
8825  * MSI AppSearch action on DrLocator table always returns absolute paths.
8826  * If a relative path was set, it returns the first absolute path that
8827  * matches or an empty string if it didn't find anything.
8828  * This helper function replicates this behaviour.
8829  */
8830 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
8831 {
8832     int i, size;
8833     DWORD attr, drives;
8834
8835     size = lstrlenA(relative);
8836     drives = GetLogicalDrives();
8837     lstrcpyA(absolute, "A:\\");
8838     for (i = 0; i < 26; absolute[0] = '\0', i++)
8839     {
8840         if (!(drives & (1 << i)))
8841             continue;
8842
8843         absolute[0] = 'A' + i;
8844         if (GetDriveType(absolute) != DRIVE_FIXED)
8845             continue;
8846
8847         lstrcpynA(absolute + 3, relative, size + 1);
8848         attr = GetFileAttributesA(absolute);
8849         if (attr != INVALID_FILE_ATTRIBUTES &&
8850             (attr & FILE_ATTRIBUTE_DIRECTORY))
8851         {
8852             if (absolute[3 + size - 1] != '\\')
8853                 lstrcatA(absolute, "\\");
8854             break;
8855         }
8856         absolute[3] = '\0';
8857     }
8858 }
8859
8860 static void test_appsearch_drlocator(void)
8861 {
8862     MSIHANDLE hpkg, hdb;
8863     CHAR path[MAX_PATH];
8864     CHAR prop[MAX_PATH];
8865     BOOL version;
8866     LPCSTR str;
8867     DWORD size;
8868     UINT r;
8869
8870     version = TRUE;
8871     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8872         version = FALSE;
8873
8874     DeleteFileA("test.dll");
8875
8876     create_test_file("FileName1");
8877     CreateDirectoryA("one", NULL);
8878     CreateDirectoryA("one\\two", NULL);
8879     CreateDirectoryA("one\\two\\three", NULL);
8880     create_test_file("one\\two\\three\\FileName2");
8881     CreateDirectoryA("another", NULL);
8882     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8883     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8884     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8885
8886     hdb = create_package_db();
8887     ok(hdb, "Expected a valid database handle\n");
8888
8889     r = create_appsearch_table(hdb);
8890     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8891
8892     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8893     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8894
8895     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8896     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8897
8898     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8899     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8900
8901     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8902     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8903
8904     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8905     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8906
8907     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8908     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8909
8910     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8911     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8912
8913     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8914     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8915
8916     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8917     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8918
8919     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8920     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8921
8922     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8923     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8924
8925     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8926     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8927
8928     r = create_drlocator_table(hdb);
8929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8930
8931     /* no parent, full path, depth 0, signature */
8932     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
8933     r = add_drlocator_entry(hdb, path);
8934     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8935
8936     /* no parent, full path, depth 0, no signature */
8937     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
8938     r = add_drlocator_entry(hdb, path);
8939     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8940
8941     /* no parent, relative path, depth 0, no signature */
8942     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
8943     r = add_drlocator_entry(hdb, path);
8944     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8945
8946     /* no parent, full path, depth 2, signature */
8947     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
8948     r = add_drlocator_entry(hdb, path);
8949     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8950
8951     /* no parent, full path, depth 3, signature */
8952     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
8953     r = add_drlocator_entry(hdb, path);
8954     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8955
8956     /* no parent, full path, depth 1, signature is dir */
8957     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
8958     r = add_drlocator_entry(hdb, path);
8959     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8960
8961     /* parent is in DrLocator, relative path, depth 0, signature */
8962     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
8963     r = add_drlocator_entry(hdb, path);
8964     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8965
8966     /* no parent, full path, depth 0, signature w/ version */
8967     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
8968     r = add_drlocator_entry(hdb, path);
8969     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8970
8971     /* no parent, full path, depth 0, signature w/ version, ver > max */
8972     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
8973     r = add_drlocator_entry(hdb, path);
8974     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8975
8976     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
8977     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
8978     r = add_drlocator_entry(hdb, path);
8979     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8980
8981     /* no parent, relative empty path, depth 0, no signature */
8982     sprintf(path, "'NewSignature11', '', '', 0");
8983     r = add_drlocator_entry(hdb, path);
8984     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8985
8986     r = create_reglocator_table(hdb);
8987     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8988
8989     /* parent */
8990     r = add_reglocator_entry(hdb, "'NewSignature12', 2, 'htmlfile\\shell\\open\\nonexistent', '', 1");
8991     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8992
8993     /* parent is in RegLocator, no path, depth 0, no signature */
8994     sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
8995     r = add_drlocator_entry(hdb, path);
8996     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8997
8998     r = create_signature_table(hdb);
8999     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9000
9001     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
9002     r = add_signature_entry(hdb, str);
9003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9004
9005     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
9006     r = add_signature_entry(hdb, str);
9007     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9008
9009     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
9010     r = add_signature_entry(hdb, str);
9011     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9012
9013     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
9014     r = add_signature_entry(hdb, str);
9015     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9016
9017     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
9018     r = add_signature_entry(hdb, str);
9019     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9020
9021     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9022     r = add_signature_entry(hdb, str);
9023     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9024
9025     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9026     r = add_signature_entry(hdb, str);
9027     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9028
9029     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9030     r = add_signature_entry(hdb, str);
9031     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9032
9033     r = package_from_db(hdb, &hpkg);
9034     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9035     {
9036         skip("Not enough rights to perform tests\n");
9037         goto error;
9038     }
9039     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9040
9041     r = MsiDoAction(hpkg, "AppSearch");
9042     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9043
9044     size = MAX_PATH;
9045     sprintf(path, "%s\\FileName1", CURR_DIR);
9046     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9048     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9049
9050     size = MAX_PATH;
9051     sprintf(path, "%s\\", CURR_DIR);
9052     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9054     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9055
9056     size = MAX_PATH;
9057     search_absolute_directory(path, CURR_DIR + 3);
9058     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9060     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9061
9062     size = MAX_PATH;
9063     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9064     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9065     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9066
9067     size = MAX_PATH;
9068     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9069     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9070     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9071     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9072
9073     size = MAX_PATH;
9074     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9075     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9076     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9077
9078     size = MAX_PATH;
9079     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9080     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9081     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9082     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9083
9084     if (version)
9085     {
9086         size = MAX_PATH;
9087         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9088         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9089         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9090         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9091
9092         size = MAX_PATH;
9093         r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9094         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9095         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9096
9097         size = MAX_PATH;
9098         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9099         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9100         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9101     }
9102
9103     size = MAX_PATH;
9104     search_absolute_directory(path, "");
9105     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9106     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9107     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9108
9109     size = MAX_PATH;
9110     strcpy(path, "c:\\");
9111     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
9112     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9113     ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
9114
9115     MsiCloseHandle(hpkg);
9116
9117 error:
9118     DeleteFileA("FileName1");
9119     DeleteFileA("FileName3.dll");
9120     DeleteFileA("FileName4.dll");
9121     DeleteFileA("FileName5.dll");
9122     DeleteFileA("one\\two\\three\\FileName2");
9123     RemoveDirectoryA("one\\two\\three");
9124     RemoveDirectoryA("one\\two");
9125     RemoveDirectoryA("one");
9126     RemoveDirectoryA("another");
9127     DeleteFileA(msifile);
9128 }
9129
9130 static void test_featureparents(void)
9131 {
9132     MSIHANDLE hpkg;
9133     UINT r;
9134     MSIHANDLE hdb;
9135     INSTALLSTATE state, action;
9136
9137     hdb = create_package_db();
9138     ok ( hdb, "failed to create package database\n" );
9139
9140     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
9141     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
9142
9143     r = create_feature_table( hdb );
9144     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
9145
9146     r = create_component_table( hdb );
9147     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
9148
9149     r = create_feature_components_table( hdb );
9150     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
9151
9152     r = create_file_table( hdb );
9153     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
9154
9155     /* msidbFeatureAttributesFavorLocal */
9156     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
9157     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9158
9159     /* msidbFeatureAttributesFavorSource */
9160     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
9161     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9162
9163     /* msidbFeatureAttributesFavorLocal */
9164     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
9165     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9166
9167     /* disabled because of install level */
9168     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
9169     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9170
9171     /* child feature of disabled feature */
9172     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
9173     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9174
9175     /* component of disabled feature (install level) */
9176     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
9177     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9178
9179     /* component of disabled child feature (install level) */
9180     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
9181     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9182
9183     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9184     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
9185     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9186
9187     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9188     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
9189     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9190
9191     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9192     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
9193     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9194
9195     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
9196     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
9197     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9198
9199     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
9200     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
9201     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9202
9203     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
9204     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
9205     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9206
9207     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9208     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
9209     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9210
9211     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9212     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
9213     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9214
9215     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9216     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
9217
9218     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
9219     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9220
9221     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
9222     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9223
9224     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
9225     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9226
9227     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
9228     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9229
9230     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
9231     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9232
9233     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
9234     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9235
9236     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
9237     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9238
9239     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
9240     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9241
9242     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
9243     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9244
9245     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
9246     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9247
9248     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
9249     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9250
9251     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
9252     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9253
9254     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
9255     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9256
9257     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
9258     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9259
9260     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
9261     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9262
9263     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
9264     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9265
9266     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
9267     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9268
9269     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
9270     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9271
9272     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
9273     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9274
9275     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9276     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9277
9278     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9279     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9280
9281     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9282     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9283
9284     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9285     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9286
9287     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9288     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9289
9290     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9291     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9292
9293     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9294     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9295
9296     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9297     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9298
9299     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9300     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9301
9302     r = package_from_db( hdb, &hpkg );
9303     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9304     {
9305         skip("Not enough rights to perform tests\n");
9306         DeleteFile(msifile);
9307         return;
9308     }
9309     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9310
9311     MsiCloseHandle( hdb );
9312
9313     r = MsiDoAction( hpkg, "CostInitialize");
9314     ok( r == ERROR_SUCCESS, "cost init failed\n");
9315
9316     r = MsiDoAction( hpkg, "FileCost");
9317     ok( r == ERROR_SUCCESS, "file cost failed\n");
9318
9319     r = MsiDoAction( hpkg, "CostFinalize");
9320     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9321
9322     state = 0xdeadbee;
9323     action = 0xdeadbee;
9324     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9326     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9327     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9328
9329     state = 0xdeadbee;
9330     action = 0xdeadbee;
9331     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9333     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9334     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9335
9336     state = 0xdeadbee;
9337     action = 0xdeadbee;
9338     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9340     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9341     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9342
9343     state = 0xdeadbee;
9344     action = 0xdeadbee;
9345     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9347     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9348     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9349
9350     state = 0xdeadbee;
9351     action = 0xdeadbee;
9352     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9354     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9355     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9356
9357     state = 0xdeadbee;
9358     action = 0xdeadbee;
9359     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9361     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9362     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9363
9364     state = 0xdeadbee;
9365     action = 0xdeadbee;
9366     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9368     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9369     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9370
9371     state = 0xdeadbee;
9372     action = 0xdeadbee;
9373     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9375     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9376     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9377
9378     state = 0xdeadbee;
9379     action = 0xdeadbee;
9380     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9382     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9383     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9384
9385     state = 0xdeadbee;
9386     action = 0xdeadbee;
9387     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9388     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9389     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9390     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9391
9392     state = 0xdeadbee;
9393     action = 0xdeadbee;
9394     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9396     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9397     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9398
9399     state = 0xdeadbee;
9400     action = 0xdeadbee;
9401     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9402     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9403     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9404     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9405
9406     state = 0xdeadbee;
9407     action = 0xdeadbee;
9408     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9409     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9410     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9411     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9412
9413     state = 0xdeadbee;
9414     action = 0xdeadbee;
9415     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9416     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9417     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9418     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9419
9420     state = 0xdeadbee;
9421     action = 0xdeadbee;
9422     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9423     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9424     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9425     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9426
9427     state = 0xdeadbee;
9428     action = 0xdeadbee;
9429     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9430     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9431     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9432     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9433
9434     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9435     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9436
9437     r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
9438     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
9439
9440     state = 0xdeadbee;
9441     action = 0xdeadbee;
9442     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9443     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9444     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9445     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9446
9447     state = 0xdeadbee;
9448     action = 0xdeadbee;
9449     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9450     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9451     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9452     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9453
9454     state = 0xdeadbee;
9455     action = 0xdeadbee;
9456     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9457     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9458     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9459     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9460
9461     state = 0xdeadbee;
9462     action = 0xdeadbee;
9463     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9464     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9465     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9466     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9467
9468     state = 0xdeadbee;
9469     action = 0xdeadbee;
9470     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9471     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9472     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9473     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9474
9475     state = 0xdeadbee;
9476     action = 0xdeadbee;
9477     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9478     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9479     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9480     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9481
9482     state = 0xdeadbee;
9483     action = 0xdeadbee;
9484     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9485     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9486     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9487     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9488
9489     state = 0xdeadbee;
9490     action = 0xdeadbee;
9491     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9492     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9493     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9494     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9495
9496     state = 0xdeadbee;
9497     action = 0xdeadbee;
9498     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9499     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9500     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9501     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9502
9503     state = 0xdeadbee;
9504     action = 0xdeadbee;
9505     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9506     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9507     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9508     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9509
9510     state = 0xdeadbee;
9511     action = 0xdeadbee;
9512     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9513     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9514     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9515     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9516
9517     state = 0xdeadbee;
9518     action = 0xdeadbee;
9519     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9520     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9521     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9522     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9523
9524     state = 0xdeadbee;
9525     action = 0xdeadbee;
9526     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9527     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9528     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9529     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9530
9531     state = 0xdeadbee;
9532     action = 0xdeadbee;
9533     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9534     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9535     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9536     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9537     
9538     MsiCloseHandle(hpkg);
9539     DeleteFileA(msifile);
9540 }
9541
9542 static void test_installprops(void)
9543 {
9544     MSIHANDLE hpkg, hdb;
9545     CHAR path[MAX_PATH], buf[MAX_PATH];
9546     DWORD size, type;
9547     LANGID langid;
9548     HKEY hkey1, hkey2;
9549     int res;
9550     UINT r;
9551     REGSAM access = KEY_ALL_ACCESS;
9552     BOOL wow64;
9553
9554     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
9555         access |= KEY_WOW64_64KEY;
9556
9557     GetCurrentDirectory(MAX_PATH, path);
9558     lstrcat(path, "\\");
9559     lstrcat(path, msifile);
9560
9561     hdb = create_package_db();
9562     ok( hdb, "failed to create database\n");
9563
9564     r = package_from_db(hdb, &hpkg);
9565     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9566     {
9567         skip("Not enough rights to perform tests\n");
9568         DeleteFile(msifile);
9569         return;
9570     }
9571     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9572
9573     MsiCloseHandle(hdb);
9574
9575     size = MAX_PATH;
9576     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
9577     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9578     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9579
9580     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
9581     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
9582
9583     size = MAX_PATH;
9584     type = REG_SZ;
9585     *path = '\0';
9586     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9587     {
9588         size = MAX_PATH;
9589         type = REG_SZ;
9590         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
9591     }
9592
9593     /* win9x doesn't set this */
9594     if (*path)
9595     {
9596         size = MAX_PATH;
9597         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
9598         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9599         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9600     }
9601
9602     size = MAX_PATH;
9603     type = REG_SZ;
9604     *path = '\0';
9605     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9606     {
9607         size = MAX_PATH;
9608         type = REG_SZ;
9609         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
9610     }
9611
9612     if (*path)
9613     {
9614         size = MAX_PATH;
9615         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
9616         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9617         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9618     }
9619
9620     size = MAX_PATH;
9621     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
9622     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9623     trace("VersionDatabase = %s\n", buf);
9624
9625     size = MAX_PATH;
9626     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
9627     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9628     trace("VersionMsi = %s\n", buf);
9629
9630     size = MAX_PATH;
9631     r = MsiGetProperty(hpkg, "Date", buf, &size);
9632     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9633     trace("Date = %s\n", buf);
9634
9635     size = MAX_PATH;
9636     r = MsiGetProperty(hpkg, "Time", buf, &size);
9637     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9638     trace("Time = %s\n", buf);
9639
9640     size = MAX_PATH;
9641     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
9642     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9643     trace("PackageCode = %s\n", buf);
9644
9645     langid = GetUserDefaultLangID();
9646     sprintf(path, "%d", langid);
9647
9648     size = MAX_PATH;
9649     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
9650     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
9651     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
9652
9653     res = GetSystemMetrics(SM_CXSCREEN);
9654     size = MAX_PATH;
9655     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
9656     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9657
9658     res = GetSystemMetrics(SM_CYSCREEN);
9659     size = MAX_PATH;
9660     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
9661     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9662
9663     CloseHandle(hkey1);
9664     CloseHandle(hkey2);
9665     MsiCloseHandle(hpkg);
9666     DeleteFile(msifile);
9667 }
9668
9669 static void test_launchconditions(void)
9670 {
9671     MSIHANDLE hpkg;
9672     MSIHANDLE hdb;
9673     UINT r;
9674
9675     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9676
9677     hdb = create_package_db();
9678     ok( hdb, "failed to create package database\n" );
9679
9680     r = create_launchcondition_table( hdb );
9681     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
9682
9683     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
9684     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9685
9686     /* invalid condition */
9687     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
9688     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9689
9690     r = package_from_db( hdb, &hpkg );
9691     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9692     {
9693         skip("Not enough rights to perform tests\n");
9694         DeleteFile(msifile);
9695         return;
9696     }
9697     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9698
9699     MsiCloseHandle( hdb );
9700
9701     r = MsiSetProperty( hpkg, "X", "1" );
9702     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9703
9704     /* invalid conditions are ignored */
9705     r = MsiDoAction( hpkg, "LaunchConditions" );
9706     ok( r == ERROR_SUCCESS, "cost init failed\n" );
9707
9708     /* verify LaunchConditions still does some verification */
9709     r = MsiSetProperty( hpkg, "X", "2" );
9710     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9711
9712     r = MsiDoAction( hpkg, "LaunchConditions" );
9713     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
9714
9715     MsiCloseHandle( hpkg );
9716     DeleteFile( msifile );
9717 }
9718
9719 static void test_ccpsearch(void)
9720 {
9721     MSIHANDLE hdb, hpkg;
9722     CHAR prop[MAX_PATH];
9723     DWORD size = MAX_PATH;
9724     UINT r;
9725
9726     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9727
9728     hdb = create_package_db();
9729     ok(hdb, "failed to create package database\n");
9730
9731     r = create_ccpsearch_table(hdb);
9732     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9733
9734     r = add_ccpsearch_entry(hdb, "'CCP_random'");
9735     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9736
9737     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
9738     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9739
9740     r = create_reglocator_table(hdb);
9741     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9742
9743     r = add_reglocator_entry(hdb, "'CCP_random', 0, 'htmlfile\\shell\\open\\nonexistent', '', 1");
9744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9745
9746     r = create_drlocator_table(hdb);
9747     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9748
9749     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
9750     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9751
9752     r = create_signature_table(hdb);
9753     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9754
9755     r = package_from_db(hdb, &hpkg);
9756     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9757     {
9758         skip("Not enough rights to perform tests\n");
9759         DeleteFile(msifile);
9760         return;
9761     }
9762     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9763
9764     MsiCloseHandle(hdb);
9765
9766     r = MsiDoAction(hpkg, "CCPSearch");
9767     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9768
9769     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
9770     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9771     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
9772
9773     MsiCloseHandle(hpkg);
9774     DeleteFileA(msifile);
9775 }
9776
9777 static void test_complocator(void)
9778 {
9779     MSIHANDLE hdb, hpkg;
9780     UINT r;
9781     CHAR prop[MAX_PATH];
9782     CHAR expected[MAX_PATH];
9783     DWORD size = MAX_PATH;
9784
9785     hdb = create_package_db();
9786     ok(hdb, "failed to create package database\n");
9787
9788     r = create_appsearch_table(hdb);
9789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9790
9791     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
9792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9793
9794     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
9795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9796
9797     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
9798     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9799
9800     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
9801     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9802
9803     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
9804     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9805
9806     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
9807     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9808
9809     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
9810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9811
9812     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
9813     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9814
9815     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
9816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9817
9818     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
9819     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9820
9821     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
9822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9823
9824     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
9825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9826
9827     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
9828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9829
9830     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
9831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9832
9833     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
9834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9835
9836     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
9837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9838
9839     r = create_complocator_table(hdb);
9840     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9841
9842     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
9843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9844
9845     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
9846     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9847
9848     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
9849     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9850
9851     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
9852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9853
9854     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
9855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9856
9857     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
9858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9859
9860     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
9861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9862
9863     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
9864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9865
9866     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
9867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9868
9869     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
9870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9871
9872     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
9873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9874
9875     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
9876     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9877
9878     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
9879     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9880
9881     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
9882     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9883
9884     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
9885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9886
9887     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
9888     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9889
9890     r = create_signature_table(hdb);
9891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9892
9893     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
9894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9895
9896     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
9897     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9898
9899     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
9900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9901
9902     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
9903     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9904
9905     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
9906     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9907
9908     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
9909     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9910
9911     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
9912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9913
9914     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
9915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9916
9917     r = package_from_db(hdb, &hpkg);
9918     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9919     {
9920         skip("Not enough rights to perform tests\n");
9921         DeleteFile(msifile);
9922         return;
9923     }
9924     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9925
9926     MsiCloseHandle(hdb);
9927
9928     create_test_file("abelisaurus");
9929     create_test_file("bactrosaurus");
9930     create_test_file("camelotia");
9931     create_test_file("diclonius");
9932     create_test_file("echinodon");
9933     create_test_file("falcarius");
9934     create_test_file("gallimimus");
9935     create_test_file("hagryphus");
9936     CreateDirectoryA("iguanodon", NULL);
9937     CreateDirectoryA("jobaria", NULL);
9938     CreateDirectoryA("kakuru", NULL);
9939     CreateDirectoryA("labocania", NULL);
9940     CreateDirectoryA("megaraptor", NULL);
9941     CreateDirectoryA("neosodon", NULL);
9942     CreateDirectoryA("olorotitan", NULL);
9943     CreateDirectoryA("pantydraco", NULL);
9944
9945     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
9946                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
9947     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
9948                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
9949     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
9950                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
9951     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
9952                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
9953     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
9954                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
9955     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
9956                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
9957     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
9958                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
9959     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
9960                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
9961
9962     r = MsiDoAction(hpkg, "AppSearch");
9963     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9964
9965     size = MAX_PATH;
9966     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
9967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9968
9969     lstrcpyA(expected, CURR_DIR);
9970     lstrcatA(expected, "\\abelisaurus");
9971     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9972        "Expected %s or empty string, got %s\n", expected, prop);
9973
9974     size = MAX_PATH;
9975     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
9976     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9977     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9978
9979     size = MAX_PATH;
9980     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
9981     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9982     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9983
9984     size = MAX_PATH;
9985     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
9986     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9987     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
9988
9989     size = MAX_PATH;
9990     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
9991     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9992
9993     lstrcpyA(expected, CURR_DIR);
9994     lstrcatA(expected, "\\");
9995     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
9996        "Expected %s or empty string, got %s\n", expected, prop);
9997
9998     size = MAX_PATH;
9999     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
10000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10001     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10002
10003     size = MAX_PATH;
10004     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
10005     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10006     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10007
10008     size = MAX_PATH;
10009     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
10010     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10011     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10012
10013     size = MAX_PATH;
10014     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
10015     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10016     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10017
10018     size = MAX_PATH;
10019     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
10020     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10021     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10022
10023     size = MAX_PATH;
10024     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
10025     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10026     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10027
10028     size = MAX_PATH;
10029     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
10030     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10031     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10032
10033     size = MAX_PATH;
10034     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
10035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10036
10037     lstrcpyA(expected, CURR_DIR);
10038     lstrcatA(expected, "\\");
10039     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10040        "Expected %s or empty string, got %s\n", expected, prop);
10041
10042     size = MAX_PATH;
10043     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
10044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10045
10046     lstrcpyA(expected, CURR_DIR);
10047     lstrcatA(expected, "\\neosodon\\");
10048     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10049        "Expected %s or empty string, got %s\n", expected, prop);
10050
10051     size = MAX_PATH;
10052     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
10053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10054     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10055
10056     size = MAX_PATH;
10057     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
10058     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10059     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10060
10061     MsiCloseHandle(hpkg);
10062     DeleteFileA("abelisaurus");
10063     DeleteFileA("bactrosaurus");
10064     DeleteFileA("camelotia");
10065     DeleteFileA("diclonius");
10066     DeleteFileA("echinodon");
10067     DeleteFileA("falcarius");
10068     DeleteFileA("gallimimus");
10069     DeleteFileA("hagryphus");
10070     RemoveDirectoryA("iguanodon");
10071     RemoveDirectoryA("jobaria");
10072     RemoveDirectoryA("kakuru");
10073     RemoveDirectoryA("labocania");
10074     RemoveDirectoryA("megaraptor");
10075     RemoveDirectoryA("neosodon");
10076     RemoveDirectoryA("olorotitan");
10077     RemoveDirectoryA("pantydraco");
10078     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
10079                           MSIINSTALLCONTEXT_MACHINE, NULL);
10080     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
10081                           MSIINSTALLCONTEXT_MACHINE, NULL);
10082     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
10083                           MSIINSTALLCONTEXT_MACHINE, NULL);
10084     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
10085                           MSIINSTALLCONTEXT_MACHINE, NULL);
10086     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
10087                           MSIINSTALLCONTEXT_MACHINE, NULL);
10088     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
10089                           MSIINSTALLCONTEXT_MACHINE, NULL);
10090     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
10091                           MSIINSTALLCONTEXT_MACHINE, NULL);
10092     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
10093                           MSIINSTALLCONTEXT_MACHINE, NULL);
10094     DeleteFileA(msifile);
10095 }
10096
10097 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
10098 {
10099     MSIHANDLE summary;
10100     UINT r;
10101
10102     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
10103     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10104
10105     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
10106     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10107
10108     r = MsiSummaryInfoPersist(summary);
10109     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10110
10111     MsiCloseHandle(summary);
10112 }
10113
10114 static void test_MsiGetSourcePath(void)
10115 {
10116     MSIHANDLE hdb, hpkg;
10117     CHAR path[MAX_PATH];
10118     CHAR cwd[MAX_PATH];
10119     CHAR subsrc[MAX_PATH];
10120     CHAR sub2[MAX_PATH];
10121     DWORD size;
10122     UINT r;
10123
10124     lstrcpyA(cwd, CURR_DIR);
10125     lstrcatA(cwd, "\\");
10126
10127     lstrcpyA(subsrc, cwd);
10128     lstrcatA(subsrc, "subsource");
10129     lstrcatA(subsrc, "\\");
10130
10131     lstrcpyA(sub2, subsrc);
10132     lstrcatA(sub2, "sub2");
10133     lstrcatA(sub2, "\\");
10134
10135     /* uncompressed source */
10136
10137     hdb = create_package_db();
10138     ok( hdb, "failed to create database\n");
10139
10140     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10141
10142     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10143     ok(r == S_OK, "failed\n");
10144
10145     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
10146     ok(r == S_OK, "failed\n");
10147
10148     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
10149     ok(r == S_OK, "failed\n");
10150
10151     r = MsiDatabaseCommit(hdb);
10152     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
10153
10154     r = package_from_db(hdb, &hpkg);
10155     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10156     {
10157         skip("Not enough rights to perform tests\n");
10158         DeleteFile(msifile);
10159         return;
10160     }
10161     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10162
10163     MsiCloseHandle(hdb);
10164
10165     /* invalid database handle */
10166     size = MAX_PATH;
10167     lstrcpyA(path, "kiwi");
10168     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
10169     ok(r == ERROR_INVALID_HANDLE,
10170        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
10171     ok(!lstrcmpA(path, "kiwi"),
10172        "Expected path to be unchanged, got \"%s\"\n", path);
10173     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10174
10175     /* NULL szFolder */
10176     size = MAX_PATH;
10177     lstrcpyA(path, "kiwi");
10178     r = MsiGetSourcePath(hpkg, NULL, path, &size);
10179     ok(r == ERROR_INVALID_PARAMETER,
10180        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10181     ok(!lstrcmpA(path, "kiwi"),
10182        "Expected path to be unchanged, got \"%s\"\n", path);
10183     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10184
10185     /* empty szFolder */
10186     size = MAX_PATH;
10187     lstrcpyA(path, "kiwi");
10188     r = MsiGetSourcePath(hpkg, "", path, &size);
10189     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10190     ok(!lstrcmpA(path, "kiwi"),
10191        "Expected path to be unchanged, got \"%s\"\n", path);
10192     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10193
10194     /* try TARGETDIR */
10195     size = MAX_PATH;
10196     lstrcpyA(path, "kiwi");
10197     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10198     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10199     ok(!lstrcmpA(path, "kiwi"),
10200        "Expected path to be unchanged, got \"%s\"\n", path);
10201     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10202
10203     size = MAX_PATH;
10204     lstrcpyA(path, "kiwi");
10205     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10206     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10207     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10208     ok(size == 0, "Expected 0, got %d\n", size);
10209
10210     size = MAX_PATH;
10211     lstrcpyA(path, "kiwi");
10212     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10214     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10215     ok(size == 0, "Expected 0, got %d\n", size);
10216
10217     /* try SourceDir */
10218     size = MAX_PATH;
10219     lstrcpyA(path, "kiwi");
10220     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10221     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10222     ok(!lstrcmpA(path, "kiwi"),
10223        "Expected path to be unchanged, got \"%s\"\n", path);
10224     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10225
10226     /* try SOURCEDIR */
10227     size = MAX_PATH;
10228     lstrcpyA(path, "kiwi");
10229     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10230     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10231     ok(!lstrcmpA(path, "kiwi"),
10232        "Expected path to be unchanged, got \"%s\"\n", path);
10233     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10234
10235     /* source path does not exist, but the property exists */
10236     size = MAX_PATH;
10237     lstrcpyA(path, "kiwi");
10238     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10239     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10240     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10241     ok(size == 0, "Expected 0, got %d\n", size);
10242
10243     size = MAX_PATH;
10244     lstrcpyA(path, "kiwi");
10245     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10246     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10247     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10248     ok(size == 0, "Expected 0, got %d\n", size);
10249
10250     /* try SubDir */
10251     size = MAX_PATH;
10252     lstrcpyA(path, "kiwi");
10253     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10254     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10255     ok(!lstrcmpA(path, "kiwi"),
10256        "Expected path to be unchanged, got \"%s\"\n", path);
10257     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10258
10259     /* try SubDir2 */
10260     size = MAX_PATH;
10261     lstrcpyA(path, "kiwi");
10262     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10263     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10264     ok(!lstrcmpA(path, "kiwi"),
10265        "Expected path to be unchanged, got \"%s\"\n", path);
10266     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10267
10268     r = MsiDoAction(hpkg, "CostInitialize");
10269     ok(r == ERROR_SUCCESS, "cost init failed\n");
10270
10271     /* try TARGETDIR after CostInitialize */
10272     size = MAX_PATH;
10273     lstrcpyA(path, "kiwi");
10274     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10275     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10276     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10277     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10278
10279     /* try SourceDir after CostInitialize */
10280     size = MAX_PATH;
10281     lstrcpyA(path, "kiwi");
10282     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10283     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10284     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10285     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10286
10287     /* try SOURCEDIR after CostInitialize */
10288     size = MAX_PATH;
10289     lstrcpyA(path, "kiwi");
10290     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10291     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10292     ok(!lstrcmpA(path, "kiwi"),
10293        "Expected path to be unchanged, got \"%s\"\n", path);
10294     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10295
10296     /* source path does not exist, but the property exists */
10297     size = MAX_PATH;
10298     lstrcpyA(path, "kiwi");
10299     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10301     todo_wine
10302     {
10303         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10304         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10305     }
10306
10307     /* try SubDir after CostInitialize */
10308     size = MAX_PATH;
10309     lstrcpyA(path, "kiwi");
10310     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10311     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10312     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10313     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10314
10315     /* try SubDir2 after CostInitialize */
10316     size = MAX_PATH;
10317     lstrcpyA(path, "kiwi");
10318     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10319     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10320     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10321     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10322
10323     r = MsiDoAction(hpkg, "ResolveSource");
10324     ok(r == ERROR_SUCCESS, "file cost failed\n");
10325
10326     /* try TARGETDIR after ResolveSource */
10327     size = MAX_PATH;
10328     lstrcpyA(path, "kiwi");
10329     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10330     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10331     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10332     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10333
10334     /* try SourceDir after ResolveSource */
10335     size = MAX_PATH;
10336     lstrcpyA(path, "kiwi");
10337     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10338     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10339     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10340     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10341
10342     /* try SOURCEDIR after ResolveSource */
10343     size = MAX_PATH;
10344     lstrcpyA(path, "kiwi");
10345     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10346     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10347     ok(!lstrcmpA(path, "kiwi"),
10348        "Expected path to be unchanged, got \"%s\"\n", path);
10349     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10350
10351     /* source path does not exist, but the property exists */
10352     size = MAX_PATH;
10353     lstrcpyA(path, "kiwi");
10354     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10355     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10356     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10357     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10358
10359     /* try SubDir after ResolveSource */
10360     size = MAX_PATH;
10361     lstrcpyA(path, "kiwi");
10362     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10363     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10364     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10365     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10366
10367     /* try SubDir2 after ResolveSource */
10368     size = MAX_PATH;
10369     lstrcpyA(path, "kiwi");
10370     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10371     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10372     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10373     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10374
10375     r = MsiDoAction(hpkg, "FileCost");
10376     ok(r == ERROR_SUCCESS, "file cost failed\n");
10377
10378     /* try TARGETDIR after FileCost */
10379     size = MAX_PATH;
10380     lstrcpyA(path, "kiwi");
10381     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10383     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10384     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10385
10386     /* try SourceDir after FileCost */
10387     size = MAX_PATH;
10388     lstrcpyA(path, "kiwi");
10389     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10390     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10391     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10392     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10393
10394     /* try SOURCEDIR after FileCost */
10395     size = MAX_PATH;
10396     lstrcpyA(path, "kiwi");
10397     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10398     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10399     ok(!lstrcmpA(path, "kiwi"),
10400        "Expected path to be unchanged, got \"%s\"\n", path);
10401     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10402
10403     /* source path does not exist, but the property exists */
10404     size = MAX_PATH;
10405     lstrcpyA(path, "kiwi");
10406     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10408     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10409     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10410
10411     /* try SubDir after FileCost */
10412     size = MAX_PATH;
10413     lstrcpyA(path, "kiwi");
10414     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10416     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10417     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10418
10419     /* try SubDir2 after FileCost */
10420     size = MAX_PATH;
10421     lstrcpyA(path, "kiwi");
10422     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10423     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10424     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10425     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10426
10427     r = MsiDoAction(hpkg, "CostFinalize");
10428     ok(r == ERROR_SUCCESS, "file cost failed\n");
10429
10430     /* try TARGETDIR after CostFinalize */
10431     size = MAX_PATH;
10432     lstrcpyA(path, "kiwi");
10433     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10434     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10435     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10436     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10437
10438     /* try SourceDir after CostFinalize */
10439     size = MAX_PATH;
10440     lstrcpyA(path, "kiwi");
10441     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10443     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10444     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10445
10446     /* try SOURCEDIR after CostFinalize */
10447     size = MAX_PATH;
10448     lstrcpyA(path, "kiwi");
10449     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10450     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10451     ok(!lstrcmpA(path, "kiwi"),
10452        "Expected path to be unchanged, got \"%s\"\n", path);
10453     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10454
10455     /* source path does not exist, but the property exists */
10456     size = MAX_PATH;
10457     lstrcpyA(path, "kiwi");
10458     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10460     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10461     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10462
10463     /* try SubDir after CostFinalize */
10464     size = MAX_PATH;
10465     lstrcpyA(path, "kiwi");
10466     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10467     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10468     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10469     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10470
10471     /* try SubDir2 after CostFinalize */
10472     size = MAX_PATH;
10473     lstrcpyA(path, "kiwi");
10474     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10476     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10477     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10478
10479     /* nonexistent directory */
10480     size = MAX_PATH;
10481     lstrcpyA(path, "kiwi");
10482     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
10483     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10484     ok(!lstrcmpA(path, "kiwi"),
10485        "Expected path to be unchanged, got \"%s\"\n", path);
10486     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10487
10488     /* NULL szPathBuf */
10489     size = MAX_PATH;
10490     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
10491     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10492     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10493
10494     /* NULL pcchPathBuf */
10495     lstrcpyA(path, "kiwi");
10496     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
10497     ok(r == ERROR_INVALID_PARAMETER,
10498        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10499     ok(!lstrcmpA(path, "kiwi"),
10500        "Expected path to be unchanged, got \"%s\"\n", path);
10501
10502     /* pcchPathBuf is 0 */
10503     size = 0;
10504     lstrcpyA(path, "kiwi");
10505     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10506     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10507     ok(!lstrcmpA(path, "kiwi"),
10508        "Expected path to be unchanged, got \"%s\"\n", path);
10509     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10510
10511     /* pcchPathBuf does not have room for NULL terminator */
10512     size = lstrlenA(cwd);
10513     lstrcpyA(path, "kiwi");
10514     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10515     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10516     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
10517        "Expected path with no backslash, got \"%s\"\n", path);
10518     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10519
10520     /* pcchPathBuf has room for NULL terminator */
10521     size = lstrlenA(cwd) + 1;
10522     lstrcpyA(path, "kiwi");
10523     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10524     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10525     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10526     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10527
10528     /* remove property */
10529     r = MsiSetProperty(hpkg, "SourceDir", NULL);
10530     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10531
10532     /* try SourceDir again */
10533     size = MAX_PATH;
10534     lstrcpyA(path, "kiwi");
10535     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10536     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10537     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10538     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10539
10540     /* set property to a valid directory */
10541     r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
10542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10543
10544     /* try SOURCEDIR again */
10545     size = MAX_PATH;
10546     lstrcpyA(path, "kiwi");
10547     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10548     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10549     ok(!lstrcmpA(path, "kiwi"),
10550        "Expected path to be unchanged, got \"%s\"\n", path);
10551     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10552
10553     MsiCloseHandle(hpkg);
10554
10555     /* compressed source */
10556
10557     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
10558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10559
10560     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
10561
10562     r = package_from_db(hdb, &hpkg);
10563     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10564
10565     /* try TARGETDIR */
10566     size = MAX_PATH;
10567     lstrcpyA(path, "kiwi");
10568     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10569     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10570     ok(!lstrcmpA(path, "kiwi"),
10571        "Expected path to be unchanged, got \"%s\"\n", path);
10572     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10573
10574     /* try SourceDir */
10575     size = MAX_PATH;
10576     lstrcpyA(path, "kiwi");
10577     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10578     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10579     ok(!lstrcmpA(path, "kiwi"),
10580        "Expected path to be unchanged, got \"%s\"\n", path);
10581     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10582
10583     /* try SOURCEDIR */
10584     size = MAX_PATH;
10585     lstrcpyA(path, "kiwi");
10586     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10587     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10588     ok(!lstrcmpA(path, "kiwi"),
10589        "Expected path to be unchanged, got \"%s\"\n", path);
10590     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10591
10592     /* source path nor the property exist */
10593     size = MAX_PATH;
10594     lstrcpyA(path, "kiwi");
10595     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10596     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10597     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10598     ok(size == 0, "Expected 0, got %d\n", size);
10599
10600     /* try SubDir */
10601     size = MAX_PATH;
10602     lstrcpyA(path, "kiwi");
10603     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10604     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10605     ok(!lstrcmpA(path, "kiwi"),
10606        "Expected path to be unchanged, got \"%s\"\n", path);
10607     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10608
10609     /* try SubDir2 */
10610     size = MAX_PATH;
10611     lstrcpyA(path, "kiwi");
10612     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10613     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10614     ok(!lstrcmpA(path, "kiwi"),
10615        "Expected path to be unchanged, got \"%s\"\n", path);
10616     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10617
10618     r = MsiDoAction(hpkg, "CostInitialize");
10619     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10620
10621     /* try TARGETDIR after CostInitialize */
10622     size = MAX_PATH;
10623     lstrcpyA(path, "kiwi");
10624     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10625     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10626     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10627     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10628
10629     /* try SourceDir after CostInitialize */
10630     size = MAX_PATH;
10631     lstrcpyA(path, "kiwi");
10632     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10633     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10634     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10635     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10636
10637     /* try SOURCEDIR after CostInitialize */
10638     size = MAX_PATH;
10639     lstrcpyA(path, "kiwi");
10640     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10641     todo_wine
10642     {
10643         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10644         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10645         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10646     }
10647
10648     /* source path does not exist, but the property exists */
10649     size = MAX_PATH;
10650     lstrcpyA(path, "kiwi");
10651     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10652     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10653     todo_wine
10654     {
10655         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10656         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10657     }
10658
10659     /* try SubDir after CostInitialize */
10660     size = MAX_PATH;
10661     lstrcpyA(path, "kiwi");
10662     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10663     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10664     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10665     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10666
10667     /* try SubDir2 after CostInitialize */
10668     size = MAX_PATH;
10669     lstrcpyA(path, "kiwi");
10670     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10671     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10672     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10673     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10674
10675     r = MsiDoAction(hpkg, "ResolveSource");
10676     ok(r == ERROR_SUCCESS, "file cost failed\n");
10677
10678     /* try TARGETDIR after ResolveSource */
10679     size = MAX_PATH;
10680     lstrcpyA(path, "kiwi");
10681     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10683     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10684     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10685
10686     /* try SourceDir after ResolveSource */
10687     size = MAX_PATH;
10688     lstrcpyA(path, "kiwi");
10689     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10690     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10691     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10692     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10693
10694     /* try SOURCEDIR after ResolveSource */
10695     size = MAX_PATH;
10696     lstrcpyA(path, "kiwi");
10697     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10698     todo_wine
10699     {
10700         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10701         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10702         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10703     }
10704
10705     /* source path and the property exist */
10706     size = MAX_PATH;
10707     lstrcpyA(path, "kiwi");
10708     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10709     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10710     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10711     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10712
10713     /* try SubDir after ResolveSource */
10714     size = MAX_PATH;
10715     lstrcpyA(path, "kiwi");
10716     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10717     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10718     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10719     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10720
10721     /* try SubDir2 after ResolveSource */
10722     size = MAX_PATH;
10723     lstrcpyA(path, "kiwi");
10724     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10726     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10727     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10728
10729     r = MsiDoAction(hpkg, "FileCost");
10730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10731
10732     /* try TARGETDIR after CostFinalize */
10733     size = MAX_PATH;
10734     lstrcpyA(path, "kiwi");
10735     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10736     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10737     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10738     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10739
10740     /* try SourceDir after CostFinalize */
10741     size = MAX_PATH;
10742     lstrcpyA(path, "kiwi");
10743     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10745     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10746     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10747
10748     /* try SOURCEDIR after CostFinalize */
10749     size = MAX_PATH;
10750     lstrcpyA(path, "kiwi");
10751     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10752     todo_wine
10753     {
10754         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10755         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10756         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10757     }
10758
10759     /* source path and the property exist */
10760     size = MAX_PATH;
10761     lstrcpyA(path, "kiwi");
10762     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10763     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10764     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10765     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10766
10767     /* try SubDir after CostFinalize */
10768     size = MAX_PATH;
10769     lstrcpyA(path, "kiwi");
10770     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10772     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10773     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10774
10775     /* try SubDir2 after CostFinalize */
10776     size = MAX_PATH;
10777     lstrcpyA(path, "kiwi");
10778     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10779     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10780     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10781     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10782
10783     r = MsiDoAction(hpkg, "CostFinalize");
10784     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10785
10786     /* try TARGETDIR after CostFinalize */
10787     size = MAX_PATH;
10788     lstrcpyA(path, "kiwi");
10789     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10791     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10792     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10793
10794     /* try SourceDir after CostFinalize */
10795     size = MAX_PATH;
10796     lstrcpyA(path, "kiwi");
10797     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10798     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10799     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10800     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10801
10802     /* try SOURCEDIR after CostFinalize */
10803     size = MAX_PATH;
10804     lstrcpyA(path, "kiwi");
10805     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10806     todo_wine
10807     {
10808         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10809         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10810         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10811     }
10812
10813     /* source path and the property exist */
10814     size = MAX_PATH;
10815     lstrcpyA(path, "kiwi");
10816     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10817     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10818     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10819     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10820
10821     /* try SubDir after CostFinalize */
10822     size = MAX_PATH;
10823     lstrcpyA(path, "kiwi");
10824     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10826     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10827     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10828
10829     /* try SubDir2 after CostFinalize */
10830     size = MAX_PATH;
10831     lstrcpyA(path, "kiwi");
10832     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10833     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10834     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10835     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10836
10837     MsiCloseHandle(hpkg);
10838     DeleteFile(msifile);
10839 }
10840
10841 static void test_shortlongsource(void)
10842 {
10843     MSIHANDLE hdb, hpkg;
10844     CHAR path[MAX_PATH];
10845     CHAR cwd[MAX_PATH];
10846     CHAR subsrc[MAX_PATH];
10847     DWORD size;
10848     UINT r;
10849
10850     lstrcpyA(cwd, CURR_DIR);
10851     lstrcatA(cwd, "\\");
10852
10853     lstrcpyA(subsrc, cwd);
10854     lstrcatA(subsrc, "long");
10855     lstrcatA(subsrc, "\\");
10856
10857     /* long file names */
10858
10859     hdb = create_package_db();
10860     ok( hdb, "failed to create database\n");
10861
10862     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10863
10864     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10865     ok(r == S_OK, "failed\n");
10866
10867     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
10868     ok(r == S_OK, "failed\n");
10869
10870     /* CostInitialize:short */
10871     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
10872     ok(r == S_OK, "failed\n");
10873
10874     /* CostInitialize:long */
10875     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
10876     ok(r == S_OK, "failed\n");
10877
10878     /* FileCost:short */
10879     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
10880     ok(r == S_OK, "failed\n");
10881
10882     /* FileCost:long */
10883     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
10884     ok(r == S_OK, "failed\n");
10885
10886     /* CostFinalize:short */
10887     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
10888     ok(r == S_OK, "failed\n");
10889
10890     /* CostFinalize:long */
10891     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
10892     ok(r == S_OK, "failed\n");
10893
10894     MsiDatabaseCommit(hdb);
10895
10896     r = package_from_db(hdb, &hpkg);
10897     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10898     {
10899         skip("Not enough rights to perform tests\n");
10900         DeleteFile(msifile);
10901         return;
10902     }
10903     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10904
10905     MsiCloseHandle(hdb);
10906
10907     CreateDirectoryA("one", NULL);
10908     CreateDirectoryA("four", NULL);
10909
10910     r = MsiDoAction(hpkg, "CostInitialize");
10911     ok(r == ERROR_SUCCESS, "file cost failed\n");
10912
10913     CreateDirectory("five", NULL);
10914     CreateDirectory("eight", NULL);
10915
10916     r = MsiDoAction(hpkg, "FileCost");
10917     ok(r == ERROR_SUCCESS, "file cost failed\n");
10918
10919     CreateDirectory("nine", NULL);
10920     CreateDirectory("twelve", NULL);
10921
10922     r = MsiDoAction(hpkg, "CostFinalize");
10923     ok(r == ERROR_SUCCESS, "file cost failed\n");
10924
10925     /* neither short nor long source directories exist */
10926     size = MAX_PATH;
10927     lstrcpyA(path, "kiwi");
10928     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10930     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10931     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10932
10933     CreateDirectoryA("short", NULL);
10934
10935     /* short source directory exists */
10936     size = MAX_PATH;
10937     lstrcpyA(path, "kiwi");
10938     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10939     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10940     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10941     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10942
10943     CreateDirectoryA("long", NULL);
10944
10945     /* both short and long source directories exist */
10946     size = MAX_PATH;
10947     lstrcpyA(path, "kiwi");
10948     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10949     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10950     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10951     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10952
10953     lstrcpyA(subsrc, cwd);
10954     lstrcatA(subsrc, "two");
10955     lstrcatA(subsrc, "\\");
10956
10957     /* short dir exists before CostInitialize */
10958     size = MAX_PATH;
10959     lstrcpyA(path, "kiwi");
10960     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10961     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10962     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10963     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10964
10965     lstrcpyA(subsrc, cwd);
10966     lstrcatA(subsrc, "four");
10967     lstrcatA(subsrc, "\\");
10968
10969     /* long dir exists before CostInitialize */
10970     size = MAX_PATH;
10971     lstrcpyA(path, "kiwi");
10972     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
10973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10974     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10975     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10976
10977     lstrcpyA(subsrc, cwd);
10978     lstrcatA(subsrc, "six");
10979     lstrcatA(subsrc, "\\");
10980
10981     /* short dir exists before FileCost */
10982     size = MAX_PATH;
10983     lstrcpyA(path, "kiwi");
10984     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
10985     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10986     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10987     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10988
10989     lstrcpyA(subsrc, cwd);
10990     lstrcatA(subsrc, "eight");
10991     lstrcatA(subsrc, "\\");
10992
10993     /* long dir exists before FileCost */
10994     size = MAX_PATH;
10995     lstrcpyA(path, "kiwi");
10996     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
10997     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10998     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10999     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11000
11001     lstrcpyA(subsrc, cwd);
11002     lstrcatA(subsrc, "ten");
11003     lstrcatA(subsrc, "\\");
11004
11005     /* short dir exists before CostFinalize */
11006     size = MAX_PATH;
11007     lstrcpyA(path, "kiwi");
11008     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11010     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11011     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11012
11013     lstrcpyA(subsrc, cwd);
11014     lstrcatA(subsrc, "twelve");
11015     lstrcatA(subsrc, "\\");
11016
11017     /* long dir exists before CostFinalize */
11018     size = MAX_PATH;
11019     lstrcpyA(path, "kiwi");
11020     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11021     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11022     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11023     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11024
11025     MsiCloseHandle(hpkg);
11026     RemoveDirectoryA("short");
11027     RemoveDirectoryA("long");
11028     RemoveDirectoryA("one");
11029     RemoveDirectoryA("four");
11030     RemoveDirectoryA("five");
11031     RemoveDirectoryA("eight");
11032     RemoveDirectoryA("nine");
11033     RemoveDirectoryA("twelve");
11034
11035     /* short file names */
11036
11037     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11039
11040     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
11041
11042     r = package_from_db(hdb, &hpkg);
11043     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11044
11045     MsiCloseHandle(hdb);
11046
11047     CreateDirectoryA("one", NULL);
11048     CreateDirectoryA("four", NULL);
11049
11050     r = MsiDoAction(hpkg, "CostInitialize");
11051     ok(r == ERROR_SUCCESS, "file cost failed\n");
11052
11053     CreateDirectory("five", NULL);
11054     CreateDirectory("eight", NULL);
11055
11056     r = MsiDoAction(hpkg, "FileCost");
11057     ok(r == ERROR_SUCCESS, "file cost failed\n");
11058
11059     CreateDirectory("nine", NULL);
11060     CreateDirectory("twelve", NULL);
11061
11062     r = MsiDoAction(hpkg, "CostFinalize");
11063     ok(r == ERROR_SUCCESS, "file cost failed\n");
11064
11065     lstrcpyA(subsrc, cwd);
11066     lstrcatA(subsrc, "short");
11067     lstrcatA(subsrc, "\\");
11068
11069     /* neither short nor long source directories exist */
11070     size = MAX_PATH;
11071     lstrcpyA(path, "kiwi");
11072     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11073     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11074     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11075     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11076
11077     CreateDirectoryA("short", NULL);
11078
11079     /* short source directory exists */
11080     size = MAX_PATH;
11081     lstrcpyA(path, "kiwi");
11082     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11084     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11085     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11086
11087     CreateDirectoryA("long", NULL);
11088
11089     /* both short and long source directories exist */
11090     size = MAX_PATH;
11091     lstrcpyA(path, "kiwi");
11092     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11094     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11095     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11096
11097     lstrcpyA(subsrc, cwd);
11098     lstrcatA(subsrc, "one");
11099     lstrcatA(subsrc, "\\");
11100
11101     /* short dir exists before CostInitialize */
11102     size = MAX_PATH;
11103     lstrcpyA(path, "kiwi");
11104     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11106     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11107     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11108
11109     lstrcpyA(subsrc, cwd);
11110     lstrcatA(subsrc, "three");
11111     lstrcatA(subsrc, "\\");
11112
11113     /* long dir exists before CostInitialize */
11114     size = MAX_PATH;
11115     lstrcpyA(path, "kiwi");
11116     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11117     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11118     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11119     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11120
11121     lstrcpyA(subsrc, cwd);
11122     lstrcatA(subsrc, "five");
11123     lstrcatA(subsrc, "\\");
11124
11125     /* short dir exists before FileCost */
11126     size = MAX_PATH;
11127     lstrcpyA(path, "kiwi");
11128     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11130     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11131     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11132
11133     lstrcpyA(subsrc, cwd);
11134     lstrcatA(subsrc, "seven");
11135     lstrcatA(subsrc, "\\");
11136
11137     /* long dir exists before FileCost */
11138     size = MAX_PATH;
11139     lstrcpyA(path, "kiwi");
11140     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11141     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11142     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11143     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11144
11145     lstrcpyA(subsrc, cwd);
11146     lstrcatA(subsrc, "nine");
11147     lstrcatA(subsrc, "\\");
11148
11149     /* short dir exists before CostFinalize */
11150     size = MAX_PATH;
11151     lstrcpyA(path, "kiwi");
11152     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11153     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11154     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11155     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11156
11157     lstrcpyA(subsrc, cwd);
11158     lstrcatA(subsrc, "eleven");
11159     lstrcatA(subsrc, "\\");
11160
11161     /* long dir exists before CostFinalize */
11162     size = MAX_PATH;
11163     lstrcpyA(path, "kiwi");
11164     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11166     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11167     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11168
11169     MsiCloseHandle(hpkg);
11170     RemoveDirectoryA("short");
11171     RemoveDirectoryA("long");
11172     RemoveDirectoryA("one");
11173     RemoveDirectoryA("four");
11174     RemoveDirectoryA("five");
11175     RemoveDirectoryA("eight");
11176     RemoveDirectoryA("nine");
11177     RemoveDirectoryA("twelve");
11178     DeleteFileA(msifile);
11179 }
11180
11181 static void test_sourcedir(void)
11182 {
11183     MSIHANDLE hdb, hpkg;
11184     CHAR package[12];
11185     CHAR path[MAX_PATH];
11186     CHAR cwd[MAX_PATH];
11187     CHAR subsrc[MAX_PATH];
11188     DWORD size;
11189     UINT r;
11190
11191     lstrcpyA(cwd, CURR_DIR);
11192     lstrcatA(cwd, "\\");
11193
11194     lstrcpyA(subsrc, cwd);
11195     lstrcatA(subsrc, "long");
11196     lstrcatA(subsrc, "\\");
11197
11198     hdb = create_package_db();
11199     ok( hdb, "failed to create database\n");
11200
11201     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11202     ok(r == S_OK, "failed\n");
11203
11204     sprintf(package, "#%u", hdb);
11205     r = MsiOpenPackage(package, &hpkg);
11206     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11207     {
11208         skip("Not enough rights to perform tests\n");
11209         goto error;
11210     }
11211     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11212
11213     /* properties only */
11214
11215     /* SourceDir prop */
11216     size = MAX_PATH;
11217     lstrcpyA(path, "kiwi");
11218     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11219     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11220     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11221     ok(size == 0, "Expected 0, got %d\n", size);
11222
11223     /* SOURCEDIR prop */
11224     size = MAX_PATH;
11225     lstrcpyA(path, "kiwi");
11226     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11227     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11228     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11229     ok(size == 0, "Expected 0, got %d\n", size);
11230
11231     r = MsiDoAction(hpkg, "CostInitialize");
11232     ok(r == ERROR_SUCCESS, "file cost failed\n");
11233
11234     /* SourceDir after CostInitialize */
11235     size = MAX_PATH;
11236     lstrcpyA(path, "kiwi");
11237     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11238     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11239     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11240     ok(size == 0, "Expected 0, got %d\n", size);
11241
11242     /* SOURCEDIR after CostInitialize */
11243     size = MAX_PATH;
11244     lstrcpyA(path, "kiwi");
11245     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11246     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11247     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11248     ok(size == 0, "Expected 0, got %d\n", size);
11249
11250     r = MsiDoAction(hpkg, "FileCost");
11251     ok(r == ERROR_SUCCESS, "file cost failed\n");
11252
11253     /* SourceDir after FileCost */
11254     size = MAX_PATH;
11255     lstrcpyA(path, "kiwi");
11256     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11257     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11258     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11259     ok(size == 0, "Expected 0, got %d\n", size);
11260
11261     /* SOURCEDIR after FileCost */
11262     size = MAX_PATH;
11263     lstrcpyA(path, "kiwi");
11264     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11265     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11266     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11267     ok(size == 0, "Expected 0, got %d\n", size);
11268
11269     r = MsiDoAction(hpkg, "CostFinalize");
11270     ok(r == ERROR_SUCCESS, "file cost failed\n");
11271
11272     /* SourceDir after CostFinalize */
11273     size = MAX_PATH;
11274     lstrcpyA(path, "kiwi");
11275     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11276     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11277     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11278     ok(size == 0, "Expected 0, got %d\n", size);
11279
11280     /* SOURCEDIR after CostFinalize */
11281     size = MAX_PATH;
11282     lstrcpyA(path, "kiwi");
11283     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11284     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11285     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11286     ok(size == 0, "Expected 0, got %d\n", size);
11287
11288     r = MsiDoAction(hpkg, "ResolveSource");
11289     ok(r == ERROR_SUCCESS, "file cost failed\n");
11290
11291     /* SourceDir after ResolveSource */
11292     size = MAX_PATH;
11293     lstrcpyA(path, "kiwi");
11294     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11296     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11297     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11298
11299     /* SOURCEDIR after ResolveSource */
11300     size = MAX_PATH;
11301     lstrcpyA(path, "kiwi");
11302     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11303     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11304     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11305     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11306
11307     /* random casing */
11308     size = MAX_PATH;
11309     lstrcpyA(path, "kiwi");
11310     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
11311     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11312     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11313     ok(size == 0, "Expected 0, got %d\n", size);
11314
11315     MsiCloseHandle(hpkg);
11316
11317     /* reset the package state */
11318     sprintf(package, "#%i", hdb);
11319     r = MsiOpenPackage(package, &hpkg);
11320     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11321
11322     /* test how MsiGetSourcePath affects the properties */
11323
11324     /* SourceDir prop */
11325     size = MAX_PATH;
11326     lstrcpyA(path, "kiwi");
11327     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11328     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11329     todo_wine
11330     {
11331         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11332         ok(size == 0, "Expected 0, got %d\n", size);
11333     }
11334
11335     size = MAX_PATH;
11336     lstrcpyA(path, "kiwi");
11337     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11338     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11339     ok(!lstrcmpA(path, "kiwi"),
11340        "Expected path to be unchanged, got \"%s\"\n", path);
11341     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11342
11343     /* SourceDir after MsiGetSourcePath */
11344     size = MAX_PATH;
11345     lstrcpyA(path, "kiwi");
11346     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11347     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11348     todo_wine
11349     {
11350         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11351         ok(size == 0, "Expected 0, got %d\n", size);
11352     }
11353
11354     /* SOURCEDIR prop */
11355     size = MAX_PATH;
11356     lstrcpyA(path, "kiwi");
11357     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11358     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11359     todo_wine
11360     {
11361         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11362         ok(size == 0, "Expected 0, got %d\n", size);
11363     }
11364
11365     size = MAX_PATH;
11366     lstrcpyA(path, "kiwi");
11367     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11368     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11369     ok(!lstrcmpA(path, "kiwi"),
11370        "Expected path to be unchanged, got \"%s\"\n", path);
11371     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11372
11373     /* SOURCEDIR prop after MsiGetSourcePath */
11374     size = MAX_PATH;
11375     lstrcpyA(path, "kiwi");
11376     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11377     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11378     todo_wine
11379     {
11380         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11381         ok(size == 0, "Expected 0, got %d\n", size);
11382     }
11383
11384     r = MsiDoAction(hpkg, "CostInitialize");
11385     ok(r == ERROR_SUCCESS, "file cost failed\n");
11386
11387     /* SourceDir after CostInitialize */
11388     size = MAX_PATH;
11389     lstrcpyA(path, "kiwi");
11390     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11392     todo_wine
11393     {
11394         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11395         ok(size == 0, "Expected 0, got %d\n", size);
11396     }
11397
11398     size = MAX_PATH;
11399     lstrcpyA(path, "kiwi");
11400     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11401     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11402     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11403     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11404
11405     /* SourceDir after MsiGetSourcePath */
11406     size = MAX_PATH;
11407     lstrcpyA(path, "kiwi");
11408     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11409     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11410     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11411     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11412
11413     /* SOURCEDIR after CostInitialize */
11414     size = MAX_PATH;
11415     lstrcpyA(path, "kiwi");
11416     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11417     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11418     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11419     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11420
11421     /* SOURCEDIR source path still does not exist */
11422     size = MAX_PATH;
11423     lstrcpyA(path, "kiwi");
11424     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11425     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11426     ok(!lstrcmpA(path, "kiwi"),
11427        "Expected path to be unchanged, got \"%s\"\n", path);
11428     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11429
11430     r = MsiDoAction(hpkg, "FileCost");
11431     ok(r == ERROR_SUCCESS, "file cost failed\n");
11432
11433     /* SourceDir after FileCost */
11434     size = MAX_PATH;
11435     lstrcpyA(path, "kiwi");
11436     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11438     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11439     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11440
11441     /* SOURCEDIR after FileCost */
11442     size = MAX_PATH;
11443     lstrcpyA(path, "kiwi");
11444     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11445     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11446     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11447     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11448
11449     /* SOURCEDIR source path still does not exist */
11450     size = MAX_PATH;
11451     lstrcpyA(path, "kiwi");
11452     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11453     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11454     ok(!lstrcmpA(path, "kiwi"),
11455        "Expected path to be unchanged, got \"%s\"\n", path);
11456     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11457
11458     r = MsiDoAction(hpkg, "CostFinalize");
11459     ok(r == ERROR_SUCCESS, "file cost failed\n");
11460
11461     /* SourceDir after CostFinalize */
11462     size = MAX_PATH;
11463     lstrcpyA(path, "kiwi");
11464     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11466     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11467     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11468
11469     /* SOURCEDIR after CostFinalize */
11470     size = MAX_PATH;
11471     lstrcpyA(path, "kiwi");
11472     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11473     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11474     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11475     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11476
11477     /* SOURCEDIR source path still does not exist */
11478     size = MAX_PATH;
11479     lstrcpyA(path, "kiwi");
11480     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11481     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11482     ok(!lstrcmpA(path, "kiwi"),
11483        "Expected path to be unchanged, got \"%s\"\n", path);
11484     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11485
11486     r = MsiDoAction(hpkg, "ResolveSource");
11487     ok(r == ERROR_SUCCESS, "file cost failed\n");
11488
11489     /* SourceDir after ResolveSource */
11490     size = MAX_PATH;
11491     lstrcpyA(path, "kiwi");
11492     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11493     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11494     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11495     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11496
11497     /* SOURCEDIR after ResolveSource */
11498     size = MAX_PATH;
11499     lstrcpyA(path, "kiwi");
11500     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11502     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11503     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11504
11505     /* SOURCEDIR source path still does not exist */
11506     size = MAX_PATH;
11507     lstrcpyA(path, "kiwi");
11508     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11509     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11510     ok(!lstrcmpA(path, "kiwi"),
11511        "Expected path to be unchanged, got \"%s\"\n", path);
11512     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11513
11514     MsiCloseHandle(hpkg);
11515
11516 error:
11517     MsiCloseHandle(hdb);
11518     DeleteFileA(msifile);
11519 }
11520
11521 struct access_res
11522 {
11523     BOOL gothandle;
11524     DWORD lasterr;
11525     BOOL ignore;
11526 };
11527
11528 static const struct access_res create[16] =
11529 {
11530     { TRUE, ERROR_SUCCESS, TRUE },
11531     { TRUE, ERROR_SUCCESS, TRUE },
11532     { TRUE, ERROR_SUCCESS, FALSE },
11533     { TRUE, ERROR_SUCCESS, FALSE },
11534     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11535     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11536     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11537     { TRUE, ERROR_SUCCESS, FALSE },
11538     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11539     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11540     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11541     { TRUE, ERROR_SUCCESS, TRUE },
11542     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11543     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11544     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11545     { TRUE, ERROR_SUCCESS, TRUE }
11546 };
11547
11548 static const struct access_res create_commit[16] =
11549 {
11550     { TRUE, ERROR_SUCCESS, TRUE },
11551     { TRUE, ERROR_SUCCESS, TRUE },
11552     { TRUE, ERROR_SUCCESS, FALSE },
11553     { TRUE, ERROR_SUCCESS, FALSE },
11554     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11555     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11556     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11557     { TRUE, ERROR_SUCCESS, FALSE },
11558     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11559     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11560     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11561     { TRUE, ERROR_SUCCESS, TRUE },
11562     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11563     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11564     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11565     { TRUE, ERROR_SUCCESS, TRUE }
11566 };
11567
11568 static const struct access_res create_close[16] =
11569 {
11570     { TRUE, ERROR_SUCCESS, FALSE },
11571     { TRUE, ERROR_SUCCESS, FALSE },
11572     { TRUE, ERROR_SUCCESS, FALSE },
11573     { TRUE, ERROR_SUCCESS, FALSE },
11574     { TRUE, ERROR_SUCCESS, FALSE },
11575     { TRUE, ERROR_SUCCESS, FALSE },
11576     { TRUE, ERROR_SUCCESS, FALSE },
11577     { TRUE, ERROR_SUCCESS, FALSE },
11578     { TRUE, ERROR_SUCCESS, FALSE },
11579     { TRUE, ERROR_SUCCESS, FALSE },
11580     { TRUE, ERROR_SUCCESS, FALSE },
11581     { TRUE, ERROR_SUCCESS, FALSE },
11582     { TRUE, ERROR_SUCCESS, FALSE },
11583     { TRUE, ERROR_SUCCESS, FALSE },
11584     { TRUE, ERROR_SUCCESS, FALSE },
11585     { TRUE, ERROR_SUCCESS }
11586 };
11587
11588 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
11589 {
11590     DWORD access = 0, share = 0;
11591     DWORD lasterr;
11592     HANDLE hfile;
11593     int i, j, idx = 0;
11594
11595     for (i = 0; i < 4; i++)
11596     {
11597         if (i == 0) access = 0;
11598         if (i == 1) access = GENERIC_READ;
11599         if (i == 2) access = GENERIC_WRITE;
11600         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
11601
11602         for (j = 0; j < 4; j++)
11603         {
11604             if (ares[idx].ignore)
11605                 continue;
11606
11607             if (j == 0) share = 0;
11608             if (j == 1) share = FILE_SHARE_READ;
11609             if (j == 2) share = FILE_SHARE_WRITE;
11610             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
11611
11612             SetLastError(0xdeadbeef);
11613             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
11614                                 FILE_ATTRIBUTE_NORMAL, 0);
11615             lasterr = GetLastError();
11616
11617             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
11618                "(%d, handle, %d): Expected %d, got %d\n",
11619                line, idx, ares[idx].gothandle,
11620                (hfile != INVALID_HANDLE_VALUE));
11621
11622             ok(lasterr == ares[idx].lasterr ||
11623                lasterr == 0xdeadbeef, /* win9x */
11624                "(%d, lasterr, %d): Expected %d, got %d\n",
11625                line, idx, ares[idx].lasterr, lasterr);
11626
11627             CloseHandle(hfile);
11628             idx++;
11629         }
11630     }
11631 }
11632
11633 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
11634
11635 static void test_access(void)
11636 {
11637     MSIHANDLE hdb;
11638     UINT r;
11639
11640     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
11641     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11642
11643     test_file_access(msifile, create);
11644
11645     r = MsiDatabaseCommit(hdb);
11646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11647
11648     test_file_access(msifile, create_commit);
11649
11650     MsiCloseHandle(hdb);
11651
11652     test_file_access(msifile, create_close);
11653
11654     DeleteFileA(msifile);
11655
11656     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
11657     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11658
11659     test_file_access(msifile, create);
11660
11661     r = MsiDatabaseCommit(hdb);
11662     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11663
11664     test_file_access(msifile, create_commit);
11665
11666     MsiCloseHandle(hdb);
11667
11668     test_file_access(msifile, create_close);
11669
11670     DeleteFileA(msifile);
11671 }
11672
11673 static void test_emptypackage(void)
11674 {
11675     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
11676     MSIHANDLE hview = 0, hrec = 0;
11677     MSICONDITION condition;
11678     CHAR buffer[MAX_PATH];
11679     DWORD size;
11680     UINT r;
11681
11682     r = MsiOpenPackageA("", &hpkg);
11683     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11684     {
11685         skip("Not enough rights to perform tests\n");
11686         return;
11687     }
11688     todo_wine
11689     {
11690         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11691     }
11692
11693     hdb = MsiGetActiveDatabase(hpkg);
11694     todo_wine
11695     {
11696         ok(hdb != 0, "Expected a valid database handle\n");
11697     }
11698
11699     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
11700     todo_wine
11701     {
11702         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11703     }
11704     r = MsiViewExecute(hview, 0);
11705     todo_wine
11706     {
11707         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11708     }
11709
11710     r = MsiViewFetch(hview, &hrec);
11711     todo_wine
11712     {
11713         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11714     }
11715
11716     buffer[0] = 0;
11717     size = MAX_PATH;
11718     r = MsiRecordGetString(hrec, 1, buffer, &size);
11719     todo_wine
11720     {
11721         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11722         ok(!lstrcmpA(buffer, "_Property"),
11723            "Expected \"_Property\", got \"%s\"\n", buffer);
11724     }
11725
11726     MsiCloseHandle(hrec);
11727
11728     r = MsiViewFetch(hview, &hrec);
11729     todo_wine
11730     {
11731         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11732     }
11733
11734     size = MAX_PATH;
11735     r = MsiRecordGetString(hrec, 1, buffer, &size);
11736     todo_wine
11737     {
11738         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11739         ok(!lstrcmpA(buffer, "#_FolderCache"),
11740            "Expected \"_Property\", got \"%s\"\n", buffer);
11741     }
11742
11743     MsiCloseHandle(hrec);
11744     MsiViewClose(hview);
11745     MsiCloseHandle(hview);
11746
11747     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
11748     todo_wine
11749     {
11750         ok(condition == MSICONDITION_FALSE,
11751            "Expected MSICONDITION_FALSE, got %d\n", condition);
11752     }
11753
11754     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
11755     todo_wine
11756     {
11757         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11758     }
11759     r = MsiViewExecute(hview, 0);
11760     todo_wine
11761     {
11762         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11763     }
11764
11765     /* _Property table is not empty */
11766     r = MsiViewFetch(hview, &hrec);
11767     todo_wine
11768     {
11769         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11770     }
11771
11772     MsiCloseHandle(hrec);
11773     MsiViewClose(hview);
11774     MsiCloseHandle(hview);
11775
11776     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
11777     todo_wine
11778     {
11779         ok(condition == MSICONDITION_FALSE,
11780            "Expected MSICONDITION_FALSE, got %d\n", condition);
11781     }
11782
11783     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
11784     todo_wine
11785     {
11786         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11787     }
11788     r = MsiViewExecute(hview, 0);
11789     todo_wine
11790     {
11791         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11792     }
11793
11794     /* #_FolderCache is not empty */
11795     r = MsiViewFetch(hview, &hrec);
11796     todo_wine
11797     {
11798         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11799     }
11800
11801     MsiCloseHandle(hrec);
11802     MsiViewClose(hview);
11803     MsiCloseHandle(hview);
11804
11805     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
11806     todo_wine
11807     {
11808         ok(r == ERROR_BAD_QUERY_SYNTAX,
11809            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11810     }
11811
11812     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
11813     todo_wine
11814     {
11815         ok(r == ERROR_BAD_QUERY_SYNTAX,
11816            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11817     }
11818
11819     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
11820     todo_wine
11821     {
11822         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
11823            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
11824     }
11825
11826     MsiCloseHandle(hsuminfo);
11827
11828     r = MsiDatabaseCommit(hdb);
11829     todo_wine
11830     {
11831         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11832     }
11833
11834     MsiCloseHandle(hdb);
11835     MsiCloseHandle(hpkg);
11836 }
11837
11838 static void test_MsiGetProductProperty(void)
11839 {
11840     MSIHANDLE hprod, hdb;
11841     CHAR val[MAX_PATH];
11842     CHAR path[MAX_PATH];
11843     CHAR query[MAX_PATH];
11844     CHAR keypath[MAX_PATH*2];
11845     CHAR prodcode[MAX_PATH];
11846     CHAR prod_squashed[MAX_PATH];
11847     HKEY prodkey, userkey, props;
11848     DWORD size;
11849     LONG res;
11850     UINT r;
11851     SC_HANDLE scm;
11852     REGSAM access = KEY_ALL_ACCESS;
11853     BOOL wow64;
11854
11855     scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
11856     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
11857     {
11858         win_skip("Different registry keys on Win9x and WinMe\n");
11859         return;
11860     }
11861     CloseServiceHandle(scm);
11862
11863     GetCurrentDirectoryA(MAX_PATH, path);
11864     lstrcatA(path, "\\");
11865
11866     create_test_guid(prodcode, prod_squashed);
11867
11868     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
11869         access |= KEY_WOW64_64KEY;
11870
11871     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
11872     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11873
11874     r = MsiDatabaseCommit(hdb);
11875     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11876
11877     r = set_summary_info(hdb);
11878     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11879
11880     r = run_query(hdb,
11881             "CREATE TABLE `Directory` ( "
11882             "`Directory` CHAR(255) NOT NULL, "
11883             "`Directory_Parent` CHAR(255), "
11884             "`DefaultDir` CHAR(255) NOT NULL "
11885             "PRIMARY KEY `Directory`)");
11886     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11887
11888     r = run_query(hdb,
11889             "CREATE TABLE `Property` ( "
11890             "`Property` CHAR(72) NOT NULL, "
11891             "`Value` CHAR(255) "
11892             "PRIMARY KEY `Property`)");
11893     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11894
11895     sprintf(query, "INSERT INTO `Property` "
11896             "(`Property`, `Value`) "
11897             "VALUES( 'ProductCode', '%s' )", prodcode);
11898     r = run_query(hdb, query);
11899     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11900
11901     r = MsiDatabaseCommit(hdb);
11902     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11903
11904     MsiCloseHandle(hdb);
11905
11906     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
11907     lstrcatA(keypath, prod_squashed);
11908
11909     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
11910     if (res == ERROR_ACCESS_DENIED)
11911     {
11912         skip("Not enough rights to perform tests\n");
11913         DeleteFile(msifile);
11914         return;
11915     }
11916     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11917
11918     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11919     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
11920     lstrcatA(keypath, prod_squashed);
11921
11922     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
11923     if (res == ERROR_ACCESS_DENIED)
11924     {
11925         skip("Not enough rights to perform tests\n");
11926         RegDeleteKeyA(prodkey, "");
11927         RegCloseKey(prodkey);
11928         return;
11929     }
11930     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11931
11932     res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
11933     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11934
11935     lstrcpyA(val, path);
11936     lstrcatA(val, "\\");
11937     lstrcatA(val, msifile);
11938     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
11939                          (const BYTE *)val, lstrlenA(val) + 1);
11940     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11941
11942     hprod = 0xdeadbeef;
11943     r = MsiOpenProductA(prodcode, &hprod);
11944     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11945     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
11946
11947     /* hProduct is invalid */
11948     size = MAX_PATH;
11949     lstrcpyA(val, "apple");
11950     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
11951     ok(r == ERROR_INVALID_HANDLE,
11952        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11953     ok(!lstrcmpA(val, "apple"),
11954        "Expected val to be unchanged, got \"%s\"\n", val);
11955     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11956
11957     /* szProperty is NULL */
11958     size = MAX_PATH;
11959     lstrcpyA(val, "apple");
11960     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
11961     ok(r == ERROR_INVALID_PARAMETER,
11962        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11963     ok(!lstrcmpA(val, "apple"),
11964        "Expected val to be unchanged, got \"%s\"\n", val);
11965     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11966
11967     /* szProperty is empty */
11968     size = MAX_PATH;
11969     lstrcpyA(val, "apple");
11970     r = MsiGetProductPropertyA(hprod, "", val, &size);
11971     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11972     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
11973     ok(size == 0, "Expected 0, got %d\n", size);
11974
11975     /* get the property */
11976     size = MAX_PATH;
11977     lstrcpyA(val, "apple");
11978     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
11979     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11980     ok(!lstrcmpA(val, prodcode),
11981        "Expected \"%s\", got \"%s\"\n", prodcode, val);
11982     ok(size == lstrlenA(prodcode),
11983        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11984
11985     /* lpValueBuf is NULL */
11986     size = MAX_PATH;
11987     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
11988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11989     ok(size == lstrlenA(prodcode),
11990        "Expected %d, got %d\n", lstrlenA(prodcode), size);
11991
11992     /* pcchValueBuf is NULL */
11993     lstrcpyA(val, "apple");
11994     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
11995     ok(r == ERROR_INVALID_PARAMETER,
11996        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11997     ok(!lstrcmpA(val, "apple"),
11998        "Expected val to be unchanged, got \"%s\"\n", val);
11999     ok(size == lstrlenA(prodcode),
12000        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12001
12002     /* pcchValueBuf is too small */
12003     size = 4;
12004     lstrcpyA(val, "apple");
12005     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12006     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12007     ok(!strncmp(val, prodcode, 3),
12008        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
12009     ok(size == lstrlenA(prodcode),
12010        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12011
12012     /* pcchValueBuf does not leave room for NULL terminator */
12013     size = lstrlenA(prodcode);
12014     lstrcpyA(val, "apple");
12015     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12016     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12017     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
12018        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
12019     ok(size == lstrlenA(prodcode),
12020        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12021
12022     /* pcchValueBuf has enough room for NULL terminator */
12023     size = lstrlenA(prodcode) + 1;
12024     lstrcpyA(val, "apple");
12025     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12026     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12027     ok(!lstrcmpA(val, prodcode),
12028        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12029     ok(size == lstrlenA(prodcode),
12030        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12031
12032     /* nonexistent property */
12033     size = MAX_PATH;
12034     lstrcpyA(val, "apple");
12035     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
12036     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12037     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12038     ok(size == 0, "Expected 0, got %d\n", size);
12039
12040     r = MsiSetPropertyA(hprod, "NewProperty", "value");
12041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12042
12043     /* non-product property set */
12044     size = MAX_PATH;
12045     lstrcpyA(val, "apple");
12046     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
12047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12048     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12049     ok(size == 0, "Expected 0, got %d\n", size);
12050
12051     r = MsiSetPropertyA(hprod, "ProductCode", "value");
12052     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12053
12054     /* non-product property that is also a product property set */
12055     size = MAX_PATH;
12056     lstrcpyA(val, "apple");
12057     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12058     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12059     ok(!lstrcmpA(val, prodcode),
12060        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12061     ok(size == lstrlenA(prodcode),
12062        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12063
12064     MsiCloseHandle(hprod);
12065
12066     RegDeleteValueA(props, "LocalPackage");
12067     delete_key(props, "", access);
12068     RegCloseKey(props);
12069     delete_key(userkey, "", access);
12070     RegCloseKey(userkey);
12071     delete_key(prodkey, "", access);
12072     RegCloseKey(prodkey);
12073     DeleteFileA(msifile);
12074 }
12075
12076 static void test_MsiSetProperty(void)
12077 {
12078     MSIHANDLE hpkg, hdb, hrec;
12079     CHAR buf[MAX_PATH];
12080     LPCSTR query;
12081     DWORD size;
12082     UINT r;
12083
12084     r = package_from_db(create_package_db(), &hpkg);
12085     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12086     {
12087         skip("Not enough rights to perform tests\n");
12088         DeleteFile(msifile);
12089         return;
12090     }
12091     ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
12092
12093     /* invalid hInstall */
12094     r = MsiSetPropertyA(0, "Prop", "Val");
12095     ok(r == ERROR_INVALID_HANDLE,
12096        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12097
12098     /* invalid hInstall */
12099     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
12100     ok(r == ERROR_INVALID_HANDLE,
12101        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12102
12103     /* szName is NULL */
12104     r = MsiSetPropertyA(hpkg, NULL, "Val");
12105     ok(r == ERROR_INVALID_PARAMETER,
12106        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12107
12108     /* both szName and szValue are NULL */
12109     r = MsiSetPropertyA(hpkg, NULL, NULL);
12110     ok(r == ERROR_INVALID_PARAMETER,
12111        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12112
12113     /* szName is empty */
12114     r = MsiSetPropertyA(hpkg, "", "Val");
12115     ok(r == ERROR_FUNCTION_FAILED,
12116        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
12117
12118     /* szName is empty and szValue is NULL */
12119     r = MsiSetPropertyA(hpkg, "", NULL);
12120     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12121
12122     /* set a property */
12123     r = MsiSetPropertyA(hpkg, "Prop", "Val");
12124     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12125
12126     /* get the property */
12127     size = MAX_PATH;
12128     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12130     ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
12131     ok(size == 3, "Expected 3, got %d\n", size);
12132
12133     /* update the property */
12134     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
12135     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12136
12137     /* get the property */
12138     size = MAX_PATH;
12139     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12140     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12141     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
12142     ok(size == 4, "Expected 4, got %d\n", size);
12143
12144     hdb = MsiGetActiveDatabase(hpkg);
12145     ok(hdb != 0, "Expected a valid database handle\n");
12146
12147     /* set prop is not in the _Property table */
12148     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
12149     r = do_query(hdb, query, &hrec);
12150     ok(r == ERROR_BAD_QUERY_SYNTAX,
12151        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12152
12153     /* set prop is not in the Property table */
12154     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
12155     r = do_query(hdb, query, &hrec);
12156     ok(r == ERROR_BAD_QUERY_SYNTAX,
12157        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12158
12159     MsiCloseHandle(hdb);
12160
12161     /* szValue is an empty string */
12162     r = MsiSetPropertyA(hpkg, "Prop", "");
12163     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12164
12165     /* try to get the property */
12166     size = MAX_PATH;
12167     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12168     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12169     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12170     ok(size == 0, "Expected 0, got %d\n", size);
12171
12172     /* reset the property */
12173     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
12174     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12175
12176     /* delete the property */
12177     r = MsiSetPropertyA(hpkg, "Prop", NULL);
12178     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12179
12180     /* try to get the property */
12181     size = MAX_PATH;
12182     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12183     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12184     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12185     ok(size == 0, "Expected 0, got %d\n", size);
12186
12187     MsiCloseHandle(hpkg);
12188     DeleteFileA(msifile);
12189 }
12190
12191 static void test_MsiApplyMultiplePatches(void)
12192 {
12193     UINT r, type = GetDriveType(NULL);
12194
12195     if (!pMsiApplyMultiplePatchesA) {
12196         win_skip("MsiApplyMultiplePatchesA not found\n");
12197         return;
12198     }
12199
12200     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
12201     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12202
12203     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
12204     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12205
12206     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
12207     todo_wine
12208     {
12209         if (type == DRIVE_FIXED)
12210             ok(r == ERROR_PATH_NOT_FOUND,
12211                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12212         else
12213             ok(r == ERROR_INVALID_NAME,
12214                "Expected ERROR_INVALID_NAME, got %u\n", r);
12215     }
12216
12217     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
12218     todo_wine
12219     {
12220         if (type == DRIVE_FIXED)
12221             ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED,
12222                "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
12223         else
12224             ok(r == ERROR_INVALID_NAME,
12225                "Expected ERROR_INVALID_NAME, got %u\n", r);
12226     }
12227
12228     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
12229     todo_wine
12230     {
12231         if (type == DRIVE_FIXED)
12232             ok(r == ERROR_PATH_NOT_FOUND,
12233                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12234         else
12235             ok(r == ERROR_INVALID_NAME,
12236                "Expected ERROR_INVALID_NAME, got %u\n", r);
12237     }
12238
12239     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
12240     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12241
12242     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
12243     todo_wine
12244     {
12245         if (type == DRIVE_FIXED)
12246             ok(r == ERROR_PATH_NOT_FOUND,
12247                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12248         else
12249             ok(r == ERROR_INVALID_NAME,
12250                "Expected ERROR_INVALID_NAME, got %u\n", r);
12251     }
12252
12253     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
12254     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12255
12256     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
12257     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12258 }
12259
12260 static void test_MsiApplyPatch(void)
12261 {
12262     UINT r;
12263
12264     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
12265     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12266
12267     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
12268     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12269 }
12270
12271 START_TEST(package)
12272 {
12273     STATEMGRSTATUS status;
12274     BOOL ret = FALSE;
12275
12276     init_functionpointers();
12277
12278     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
12279
12280     /* Create a restore point ourselves so we circumvent the multitude of restore points
12281      * that would have been created by all the installation and removal tests.
12282      */
12283     if (pSRSetRestorePointA)
12284     {
12285         memset(&status, 0, sizeof(status));
12286         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
12287     }
12288
12289     test_createpackage();
12290     test_doaction();
12291     test_gettargetpath_bad();
12292     test_settargetpath();
12293     test_props();
12294     test_property_table();
12295     test_condition();
12296     test_msipackage();
12297     test_formatrecord2();
12298     test_states();
12299     test_getproperty();
12300     test_removefiles();
12301     test_appsearch();
12302     test_appsearch_complocator();
12303     test_appsearch_reglocator();
12304     test_appsearch_inilocator();
12305     test_appsearch_drlocator();
12306     test_featureparents();
12307     test_installprops();
12308     test_launchconditions();
12309     test_ccpsearch();
12310     test_complocator();
12311     test_MsiGetSourcePath();
12312     test_shortlongsource();
12313     test_sourcedir();
12314     test_access();
12315     test_emptypackage();
12316     test_MsiGetProductProperty();
12317     test_MsiSetProperty();
12318     test_MsiApplyMultiplePatches();
12319     test_MsiApplyPatch();
12320
12321     if (pSRSetRestorePointA && ret)
12322     {
12323         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
12324         if (ret)
12325             remove_restore_point(status.llSequenceNumber);
12326     }
12327 }