msi/tests: Fix some test failures on 64-bit.
[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 static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
45
46 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
47 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
48
49 static void init_functionpointers(void)
50 {
51     HMODULE hmsi = GetModuleHandleA("msi.dll");
52     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
53     HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
54     HMODULE hsrclient;
55
56 #define GET_PROC(mod, func) \
57     p ## func = (void*)GetProcAddress(mod, #func);
58
59     GET_PROC(hmsi, MsiApplyMultiplePatchesA);
60
61     GET_PROC(hadvapi32, ConvertSidToStringSidA);
62     GET_PROC(hadvapi32, GetTokenInformation);
63     GET_PROC(hadvapi32, OpenProcessToken);
64     GET_PROC(hadvapi32, RegDeleteKeyExA)
65     GET_PROC(hadvapi32, RegDeleteKeyExW)
66     GET_PROC(hkernel32, IsWow64Process)
67     GET_PROC(hkernel32, GetSystemInfo)
68
69     hsrclient = LoadLibraryA("srclient.dll");
70     GET_PROC(hsrclient, SRRemoveRestorePoint);
71     GET_PROC(hsrclient, SRSetRestorePointA);
72 #undef GET_PROC
73 }
74
75 static BOOL is_process_limited(void)
76 {
77     HANDLE token;
78
79     if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
80
81     if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
82     {
83         BOOL ret;
84         TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
85         DWORD size;
86
87         ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
88         CloseHandle(token);
89         return (ret && type == TokenElevationTypeLimited);
90     }
91     return FALSE;
92 }
93
94 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
95 {
96     if (pRegDeleteKeyExA)
97         return pRegDeleteKeyExA( key, subkey, access, 0 );
98     return RegDeleteKeyA( key, subkey );
99 }
100
101 static LPSTR get_user_sid(LPSTR *usersid)
102 {
103     HANDLE token;
104     BYTE buf[1024];
105     DWORD size;
106     PTOKEN_USER user;
107
108     if (!pConvertSidToStringSidA)
109     {
110         win_skip("ConvertSidToStringSidA is not available\n");
111         return NULL;
112     }
113
114     *usersid = NULL;
115     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
116     size = sizeof(buf);
117     GetTokenInformation(token, TokenUser, buf, size, &size);
118     user = (PTOKEN_USER)buf;
119     pConvertSidToStringSidA(user->User.Sid, usersid);
120     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
121     CloseHandle(token);
122     return *usersid;
123 }
124
125 /* RegDeleteTreeW from dlls/advapi32/registry.c */
126 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
127 {
128     LONG ret;
129     DWORD dwMaxSubkeyLen, dwMaxValueLen;
130     DWORD dwMaxLen, dwSize;
131     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
132     HKEY hSubKey = hKey;
133
134     if(lpszSubKey)
135     {
136         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
137         if (ret) return ret;
138     }
139
140     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
141             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
142     if (ret) goto cleanup;
143
144     dwMaxSubkeyLen++;
145     dwMaxValueLen++;
146     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
147     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
148     {
149         /* Name too big: alloc a buffer for it */
150         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
151         {
152             ret = ERROR_NOT_ENOUGH_MEMORY;
153             goto cleanup;
154         }
155     }
156
157     /* Recursively delete all the subkeys */
158     while (TRUE)
159     {
160         dwSize = dwMaxLen;
161         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
162                           NULL, NULL, NULL)) break;
163
164         ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
165         if (ret) goto cleanup;
166     }
167
168     if (lpszSubKey)
169     {
170         if (pRegDeleteKeyExW)
171             ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
172         else
173             ret = RegDeleteKeyW(hKey, lpszSubKey);
174     }
175     else
176         while (TRUE)
177         {
178             dwSize = dwMaxLen;
179             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
180                   NULL, NULL, NULL, NULL)) break;
181
182             ret = RegDeleteValueW(hKey, lpszName);
183             if (ret) goto cleanup;
184         }
185
186 cleanup:
187     if (lpszName != szNameBuf)
188         HeapFree(GetProcessHeap(), 0, lpszName);
189     if(lpszSubKey)
190         RegCloseKey(hSubKey);
191     return ret;
192 }
193
194 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
195 {
196     DWORD i,n=1;
197     GUID guid;
198
199     if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
200         return FALSE;
201
202     for(i=0; i<8; i++)
203         out[7-i] = in[n++];
204     n++;
205     for(i=0; i<4; i++)
206         out[11-i] = in[n++];
207     n++;
208     for(i=0; i<4; i++)
209         out[15-i] = in[n++];
210     n++;
211     for(i=0; i<2; i++)
212     {
213         out[17+i*2] = in[n++];
214         out[16+i*2] = in[n++];
215     }
216     n++;
217     for( ; i<8; i++)
218     {
219         out[17+i*2] = in[n++];
220         out[16+i*2] = in[n++];
221     }
222     out[32]=0;
223     return TRUE;
224 }
225
226 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
227 {
228     WCHAR guidW[MAX_PATH];
229     WCHAR squashedW[MAX_PATH];
230     GUID guid;
231     HRESULT hr;
232     int size;
233
234     hr = CoCreateGuid(&guid);
235     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
236
237     size = StringFromGUID2(&guid, guidW, MAX_PATH);
238     ok(size == 39, "Expected 39, got %d\n", hr);
239
240     WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
241     squash_guid(guidW, squashedW);
242     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
243 }
244
245 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
246                                LPCSTR guid, LPSTR usersid, BOOL dir)
247 {
248     WCHAR guidW[MAX_PATH];
249     WCHAR squashedW[MAX_PATH];
250     CHAR squashed[MAX_PATH];
251     CHAR comppath[MAX_PATH];
252     CHAR prodpath[MAX_PATH];
253     CHAR path[MAX_PATH];
254     LPCSTR prod = NULL;
255     HKEY hkey;
256     REGSAM access = KEY_ALL_ACCESS;
257     BOOL wow64;
258
259     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
260         access |= KEY_WOW64_64KEY;
261
262     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
263     squash_guid(guidW, squashedW);
264     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
265
266     if (context == MSIINSTALLCONTEXT_MACHINE)
267     {
268         prod = "3D0DAE300FACA1300AD792060BCDAA92";
269         sprintf(comppath,
270                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
271                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
272         lstrcpyA(prodpath,
273                  "SOFTWARE\\Classes\\Installer\\"
274                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
275     }
276     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
277     {
278         prod = "7D2F387510109040002000060BECB6AB";
279         sprintf(comppath,
280                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
281                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
282         sprintf(prodpath,
283                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
284                 "Installer\\%s\\Installer\\Products\\"
285                 "7D2F387510109040002000060BECB6AB", usersid);
286     }
287     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
288     {
289         prod = "7D2F387510109040002000060BECB6AB";
290         sprintf(comppath,
291                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
292                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
293         sprintf(prodpath,
294                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
295                 "Installer\\Managed\\%s\\Installer\\Products\\"
296                 "7D2F387510109040002000060BECB6AB", usersid);
297     }
298
299     RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
300
301     lstrcpyA(path, CURR_DIR);
302     lstrcatA(path, "\\");
303     if (!dir) lstrcatA(path, filename);
304
305     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
306     RegCloseKey(hkey);
307
308     RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
309     RegCloseKey(hkey);
310 }
311
312 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
313 {
314     WCHAR guidW[MAX_PATH];
315     WCHAR squashedW[MAX_PATH];
316     WCHAR substrW[MAX_PATH];
317     CHAR squashed[MAX_PATH];
318     CHAR comppath[MAX_PATH];
319     CHAR prodpath[MAX_PATH];
320     REGSAM access = KEY_ALL_ACCESS;
321     BOOL wow64;
322
323     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
324         access |= KEY_WOW64_64KEY;
325
326     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
327     squash_guid(guidW, squashedW);
328     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
329
330     if (context == MSIINSTALLCONTEXT_MACHINE)
331     {
332         sprintf(comppath,
333                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
334                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
335         lstrcpyA(prodpath,
336                  "SOFTWARE\\Classes\\Installer\\"
337                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
338     }
339     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
340     {
341         sprintf(comppath,
342                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
343                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
344         sprintf(prodpath,
345                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
346                 "Installer\\%s\\Installer\\Products\\"
347                 "7D2F387510109040002000060BECB6AB", usersid);
348     }
349     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
350     {
351         sprintf(comppath,
352                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
353                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
354         sprintf(prodpath,
355                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
356                 "Installer\\Managed\\%s\\Installer\\Products\\"
357                 "7D2F387510109040002000060BECB6AB", usersid);
358     }
359
360     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
361     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
362
363     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
364     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
365 }
366
367 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
368 {
369     MSIHANDLE hview = 0;
370     UINT r, ret;
371
372     /* open a select query */
373     r = MsiDatabaseOpenView(hdb, query, &hview);
374     if (r != ERROR_SUCCESS)
375         return r;
376     r = MsiViewExecute(hview, 0);
377     if (r != ERROR_SUCCESS)
378         return r;
379     ret = MsiViewFetch(hview, phrec);
380     r = MsiViewClose(hview);
381     if (r != ERROR_SUCCESS)
382         return r;
383     r = MsiCloseHandle(hview);
384     if (r != ERROR_SUCCESS)
385         return r;
386     return ret;
387 }
388
389 static UINT run_query( MSIHANDLE hdb, const char *query )
390 {
391     MSIHANDLE hview = 0;
392     UINT r;
393
394     r = MsiDatabaseOpenView(hdb, query, &hview);
395     if( r != ERROR_SUCCESS )
396         return r;
397
398     r = MsiViewExecute(hview, 0);
399     if( r == ERROR_SUCCESS )
400         r = MsiViewClose(hview);
401     MsiCloseHandle(hview);
402     return r;
403 }
404
405 static UINT create_component_table( MSIHANDLE hdb )
406 {
407     return run_query( hdb,
408             "CREATE TABLE `Component` ( "
409             "`Component` CHAR(72) NOT NULL, "
410             "`ComponentId` CHAR(38), "
411             "`Directory_` CHAR(72) NOT NULL, "
412             "`Attributes` SHORT NOT NULL, "
413             "`Condition` CHAR(255), "
414             "`KeyPath` CHAR(72) "
415             "PRIMARY KEY `Component`)" );
416 }
417
418 static UINT create_feature_table( MSIHANDLE hdb )
419 {
420     return run_query( hdb,
421             "CREATE TABLE `Feature` ( "
422             "`Feature` CHAR(38) NOT NULL, "
423             "`Feature_Parent` CHAR(38), "
424             "`Title` CHAR(64), "
425             "`Description` CHAR(255), "
426             "`Display` SHORT NOT NULL, "
427             "`Level` SHORT NOT NULL, "
428             "`Directory_` CHAR(72), "
429             "`Attributes` SHORT NOT NULL "
430             "PRIMARY KEY `Feature`)" );
431 }
432
433 static UINT create_feature_components_table( MSIHANDLE hdb )
434 {
435     return run_query( hdb,
436             "CREATE TABLE `FeatureComponents` ( "
437             "`Feature_` CHAR(38) NOT NULL, "
438             "`Component_` CHAR(72) NOT NULL "
439             "PRIMARY KEY `Feature_`, `Component_` )" );
440 }
441
442 static UINT create_file_table( MSIHANDLE hdb )
443 {
444     return run_query( hdb,
445             "CREATE TABLE `File` ("
446             "`File` CHAR(72) NOT NULL, "
447             "`Component_` CHAR(72) NOT NULL, "
448             "`FileName` CHAR(255) NOT NULL, "
449             "`FileSize` LONG NOT NULL, "
450             "`Version` CHAR(72), "
451             "`Language` CHAR(20), "
452             "`Attributes` SHORT, "
453             "`Sequence` SHORT NOT NULL "
454             "PRIMARY KEY `File`)" );
455 }
456
457 static UINT create_remove_file_table( MSIHANDLE hdb )
458 {
459     return run_query( hdb,
460             "CREATE TABLE `RemoveFile` ("
461             "`FileKey` CHAR(72) NOT NULL, "
462             "`Component_` CHAR(72) NOT NULL, "
463             "`FileName` CHAR(255) LOCALIZABLE, "
464             "`DirProperty` CHAR(72) NOT NULL, "
465             "`InstallMode` SHORT NOT NULL "
466             "PRIMARY KEY `FileKey`)" );
467 }
468
469 static UINT create_appsearch_table( MSIHANDLE hdb )
470 {
471     return run_query( hdb,
472             "CREATE TABLE `AppSearch` ("
473             "`Property` CHAR(72) NOT NULL, "
474             "`Signature_` CHAR(72) NOT NULL "
475             "PRIMARY KEY `Property`, `Signature_`)" );
476 }
477
478 static UINT create_reglocator_table( MSIHANDLE hdb )
479 {
480     return run_query( hdb,
481             "CREATE TABLE `RegLocator` ("
482             "`Signature_` CHAR(72) NOT NULL, "
483             "`Root` SHORT NOT NULL, "
484             "`Key` CHAR(255) NOT NULL, "
485             "`Name` CHAR(255), "
486             "`Type` SHORT "
487             "PRIMARY KEY `Signature_`)" );
488 }
489
490 static UINT create_signature_table( MSIHANDLE hdb )
491 {
492     return run_query( hdb,
493             "CREATE TABLE `Signature` ("
494             "`Signature` CHAR(72) NOT NULL, "
495             "`FileName` CHAR(255) NOT NULL, "
496             "`MinVersion` CHAR(20), "
497             "`MaxVersion` CHAR(20), "
498             "`MinSize` LONG, "
499             "`MaxSize` LONG, "
500             "`MinDate` LONG, "
501             "`MaxDate` LONG, "
502             "`Languages` CHAR(255) "
503             "PRIMARY KEY `Signature`)" );
504 }
505
506 static UINT create_launchcondition_table( MSIHANDLE hdb )
507 {
508     return run_query( hdb,
509             "CREATE TABLE `LaunchCondition` ("
510             "`Condition` CHAR(255) NOT NULL, "
511             "`Description` CHAR(255) NOT NULL "
512             "PRIMARY KEY `Condition`)" );
513 }
514
515 static UINT create_property_table( MSIHANDLE hdb )
516 {
517     return run_query( hdb,
518             "CREATE TABLE `Property` ("
519             "`Property` CHAR(72) NOT NULL, "
520             "`Value` CHAR(0) "
521             "PRIMARY KEY `Property`)" );
522 }
523
524 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
525 {
526     return run_query( hdb,
527             "CREATE TABLE `InstallExecuteSequence` ("
528             "`Action` CHAR(72) NOT NULL, "
529             "`Condition` CHAR(255), "
530             "`Sequence` SHORT "
531             "PRIMARY KEY `Action`)" );
532 }
533
534 static UINT create_media_table( MSIHANDLE hdb )
535 {
536     return run_query( hdb,
537             "CREATE TABLE `Media` ("
538             "`DiskId` SHORT NOT NULL, "
539             "`LastSequence` SHORT NOT NULL, "
540             "`DiskPrompt` CHAR(64), "
541             "`Cabinet` CHAR(255), "
542             "`VolumeLabel` CHAR(32), "
543             "`Source` CHAR(72) "
544             "PRIMARY KEY `DiskId`)" );
545 }
546
547 static UINT create_ccpsearch_table( MSIHANDLE hdb )
548 {
549     return run_query( hdb,
550             "CREATE TABLE `CCPSearch` ("
551             "`Signature_` CHAR(72) NOT NULL "
552             "PRIMARY KEY `Signature_`)" );
553 }
554
555 static UINT create_drlocator_table( MSIHANDLE hdb )
556 {
557     return run_query( hdb,
558             "CREATE TABLE `DrLocator` ("
559             "`Signature_` CHAR(72) NOT NULL, "
560             "`Parent` CHAR(72), "
561             "`Path` CHAR(255), "
562             "`Depth` SHORT "
563             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
564 }
565
566 static UINT create_complocator_table( MSIHANDLE hdb )
567 {
568     return run_query( hdb,
569             "CREATE TABLE `CompLocator` ("
570             "`Signature_` CHAR(72) NOT NULL, "
571             "`ComponentId` CHAR(38) NOT NULL, "
572             "`Type` SHORT "
573             "PRIMARY KEY `Signature_`)" );
574 }
575
576 static UINT create_inilocator_table( MSIHANDLE hdb )
577 {
578     return run_query( hdb,
579             "CREATE TABLE `IniLocator` ("
580             "`Signature_` CHAR(72) NOT NULL, "
581             "`FileName` CHAR(255) NOT NULL, "
582             "`Section` CHAR(96)NOT NULL, "
583             "`Key` CHAR(128)NOT NULL, "
584             "`Field` SHORT, "
585             "`Type` SHORT "
586             "PRIMARY KEY `Signature_`)" );
587 }
588
589 #define make_add_entry(type, qtext) \
590     static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
591     { \
592         char insert[] = qtext; \
593         char *query; \
594         UINT sz, r; \
595         sz = strlen(values) + sizeof insert; \
596         query = HeapAlloc(GetProcessHeap(),0,sz); \
597         sprintf(query,insert,values); \
598         r = run_query( hdb, query ); \
599         HeapFree(GetProcessHeap(), 0, query); \
600         return r; \
601     }
602
603 make_add_entry(component,
604                "INSERT INTO `Component`  "
605                "(`Component`, `ComponentId`, `Directory_`, "
606                "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
607
608 make_add_entry(directory,
609                "INSERT INTO `Directory` "
610                "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
611
612 make_add_entry(feature,
613                "INSERT INTO `Feature` "
614                "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
615                "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
616
617 make_add_entry(feature_components,
618                "INSERT INTO `FeatureComponents` "
619                "(`Feature_`, `Component_`) VALUES( %s )")
620
621 make_add_entry(file,
622                "INSERT INTO `File` "
623                "(`File`, `Component_`, `FileName`, `FileSize`, "
624                "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
625
626 make_add_entry(appsearch,
627                "INSERT INTO `AppSearch` "
628                "(`Property`, `Signature_`) VALUES( %s )")
629
630 make_add_entry(signature,
631                "INSERT INTO `Signature` "
632                "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
633                " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
634                "VALUES( %s )")
635
636 make_add_entry(launchcondition,
637                "INSERT INTO `LaunchCondition` "
638                "(`Condition`, `Description`) VALUES( %s )")
639
640 make_add_entry(property,
641                "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
642
643 make_add_entry(install_execute_sequence,
644                "INSERT INTO `InstallExecuteSequence` "
645                "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
646
647 make_add_entry(media,
648                "INSERT INTO `Media` "
649                "(`DiskId`, `LastSequence`, `DiskPrompt`, "
650                "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
651
652 make_add_entry(ccpsearch,
653                "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
654
655 make_add_entry(drlocator,
656                "INSERT INTO `DrLocator` "
657                "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
658
659 make_add_entry(complocator,
660                "INSERT INTO `CompLocator` "
661                "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
662
663 make_add_entry(inilocator,
664                "INSERT INTO `IniLocator` "
665                "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
666                "VALUES( %s )")
667
668 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
669                                   const char *name, UINT type )
670 {
671     const char insert[] =
672         "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
673         "VALUES( '%s', %u, '%s', '%s', %u )";
674     char *query;
675     UINT sz, r;
676
677     sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
678     query = HeapAlloc( GetProcessHeap(), 0, sz );
679     sprintf( query, insert, sig, root, path, name, type );
680     r = run_query( hdb, query );
681     HeapFree( GetProcessHeap(), 0, query );
682     return r;
683 }
684
685 static UINT set_summary_info(MSIHANDLE hdb)
686 {
687     UINT res;
688     MSIHANDLE suminfo;
689
690     /* build summary info */
691     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
692     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
693
694     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
695                         "Installation Database");
696     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
697
698     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
699                         "Installation Database");
700     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
701
702     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
703                         "Wine Hackers");
704     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
705
706     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
707                     ";1033");
708     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
709
710     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
711                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
712     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
713
714     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
715     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
716
717     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
718     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
719
720     res = MsiSummaryInfoPersist(suminfo);
721     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
722
723     res = MsiCloseHandle( suminfo);
724     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
725
726     return res;
727 }
728
729
730 static MSIHANDLE create_package_db(void)
731 {
732     MSIHANDLE hdb = 0;
733     UINT res;
734
735     DeleteFile(msifile);
736
737     /* create an empty database */
738     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
739     ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
740     if( res != ERROR_SUCCESS )
741         return hdb;
742
743     res = MsiDatabaseCommit( hdb );
744     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
745
746     res = set_summary_info(hdb);
747
748     res = run_query( hdb,
749             "CREATE TABLE `Directory` ( "
750             "`Directory` CHAR(255) NOT NULL, "
751             "`Directory_Parent` CHAR(255), "
752             "`DefaultDir` CHAR(255) NOT NULL "
753             "PRIMARY KEY `Directory`)" );
754     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
755
756     return hdb;
757 }
758
759 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
760 {
761     UINT res;
762     CHAR szPackage[12];
763     MSIHANDLE hPackage;
764
765     sprintf(szPackage, "#%u", hdb);
766     res = MsiOpenPackage(szPackage, &hPackage);
767     if (res != ERROR_SUCCESS)
768     {
769         MsiCloseHandle(hdb);
770         return res;
771     }
772
773     res = MsiCloseHandle(hdb);
774     if (res != ERROR_SUCCESS)
775     {
776         MsiCloseHandle(hPackage);
777         return res;
778     }
779
780     *handle = hPackage;
781     return ERROR_SUCCESS;
782 }
783
784 static void create_test_file(const CHAR *name)
785 {
786     HANDLE file;
787     DWORD written;
788
789     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
790     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
791     WriteFile(file, name, strlen(name), &written, NULL);
792     WriteFile(file, "\n", strlen("\n"), &written, NULL);
793     CloseHandle(file);
794 }
795
796 typedef struct _tagVS_VERSIONINFO
797 {
798     WORD wLength;
799     WORD wValueLength;
800     WORD wType;
801     WCHAR szKey[1];
802     WORD wPadding1[1];
803     VS_FIXEDFILEINFO Value;
804     WORD wPadding2[1];
805     WORD wChildren[1];
806 } VS_VERSIONINFO;
807
808 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
809 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
810
811 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
812 {
813     VS_VERSIONINFO *pVerInfo;
814     VS_FIXEDFILEINFO *pFixedInfo;
815     LPBYTE buffer, ofs;
816     CHAR path[MAX_PATH];
817     DWORD handle, size;
818     HANDLE resource;
819     BOOL ret = FALSE;
820
821     GetSystemDirectory(path, MAX_PATH);
822     /* Some dlls can't be updated on Vista/W2K8 */
823     lstrcatA(path, "\\version.dll");
824
825     CopyFileA(path, name, FALSE);
826
827     size = GetFileVersionInfoSize(path, &handle);
828     buffer = HeapAlloc(GetProcessHeap(), 0, size);
829
830     GetFileVersionInfoA(path, 0, size, buffer);
831
832     pVerInfo = (VS_VERSIONINFO *)buffer;
833     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
834     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
835
836     pFixedInfo->dwFileVersionMS = ms;
837     pFixedInfo->dwFileVersionLS = ls;
838     pFixedInfo->dwProductVersionMS = ms;
839     pFixedInfo->dwProductVersionLS = ls;
840
841     resource = BeginUpdateResource(name, FALSE);
842     if (!resource)
843         goto done;
844
845     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
846                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
847         goto done;
848
849     if (!EndUpdateResource(resource, FALSE))
850         goto done;
851
852     ret = TRUE;
853
854 done:
855     HeapFree(GetProcessHeap(), 0, buffer);
856     return ret;
857 }
858
859 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
860 {
861     RESTOREPOINTINFOA spec;
862
863     spec.dwEventType = event_type;
864     spec.dwRestorePtType = APPLICATION_INSTALL;
865     spec.llSequenceNumber = status->llSequenceNumber;
866     lstrcpyA(spec.szDescription, "msitest restore point");
867
868     return pSRSetRestorePointA(&spec, status);
869 }
870
871 static void remove_restore_point(DWORD seq_number)
872 {
873     DWORD res;
874
875     res = pSRRemoveRestorePoint(seq_number);
876     if (res != ERROR_SUCCESS)
877         trace("Failed to remove the restore point : %08x\n", res);
878 }
879
880 static void test_createpackage(void)
881 {
882     MSIHANDLE hPackage = 0;
883     UINT res;
884
885     res = package_from_db(create_package_db(), &hPackage);
886     if (res == ERROR_INSTALL_PACKAGE_REJECTED)
887     {
888         skip("Not enough rights to perform tests\n");
889         DeleteFile(msifile);
890         return;
891     }
892     ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
893
894     res = MsiCloseHandle( hPackage);
895     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
896     DeleteFile(msifile);
897 }
898
899 static void test_doaction( void )
900 {
901     MSIHANDLE hpkg;
902     UINT r;
903
904     r = MsiDoAction( -1, NULL );
905     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
906
907     r = package_from_db(create_package_db(), &hpkg);
908     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
909     {
910         skip("Not enough rights to perform tests\n");
911         DeleteFile(msifile);
912         return;
913     }
914     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
915
916     r = MsiDoAction(hpkg, NULL);
917     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
918
919     r = MsiDoAction(0, "boo");
920     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
921
922     r = MsiDoAction(hpkg, "boo");
923     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
924
925     MsiCloseHandle( hpkg );
926     DeleteFile(msifile);
927 }
928
929 static void test_gettargetpath_bad(void)
930 {
931     static const WCHAR boo[] = {'b','o','o',0};
932     static const WCHAR empty[] = {0};
933     char buffer[0x80];
934     WCHAR bufferW[0x80];
935     MSIHANDLE hpkg;
936     DWORD sz;
937     UINT r;
938
939     r = package_from_db(create_package_db(), &hpkg);
940     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
941     {
942         skip("Not enough rights to perform tests\n");
943         DeleteFile(msifile);
944         return;
945     }
946     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
947
948     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
949     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
950
951     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
952     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
953
954     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
955     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
956
957     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
958     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
959
960     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
961     ok( r == ERROR_DIRECTORY, "wrong return val\n");
962
963     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
964     ok( r == ERROR_DIRECTORY, "wrong return val\n");
965
966     sz = 0;
967     r = MsiGetTargetPath( hpkg, "", buffer, &sz );
968     ok( r == ERROR_DIRECTORY, "wrong return val\n");
969
970     r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
971     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
972
973     r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
974     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
975
976     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
977     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
978
979     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
980     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
981
982     r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
983     ok( r == ERROR_DIRECTORY, "wrong return val\n");
984
985     r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
986     ok( r == ERROR_DIRECTORY, "wrong return val\n");
987
988     sz = 0;
989     r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
990     ok( r == ERROR_DIRECTORY, "wrong return val\n");
991
992     MsiCloseHandle( hpkg );
993     DeleteFile(msifile);
994 }
995
996 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
997 {
998     UINT r;
999     DWORD size;
1000     MSIHANDLE rec;
1001
1002     rec = MsiCreateRecord( 1 );
1003     ok(rec, "MsiCreate record failed\n");
1004
1005     r = MsiRecordSetString( rec, 0, file );
1006     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1007
1008     size = MAX_PATH;
1009     r = MsiFormatRecord( hpkg, rec, buff, &size );
1010     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1011
1012     MsiCloseHandle( rec );
1013 }
1014
1015 static void test_settargetpath(void)
1016 {
1017     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1018     DWORD sz;
1019     MSIHANDLE hpkg;
1020     UINT r;
1021     MSIHANDLE hdb;
1022
1023     hdb = create_package_db();
1024     ok ( hdb, "failed to create package database\n" );
1025
1026     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1027     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1028
1029     r = create_component_table( hdb );
1030     ok( r == S_OK, "cannot create Component table: %d\n", r );
1031
1032     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1033     ok( r == S_OK, "cannot add dummy component: %d\n", r );
1034
1035     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1036     ok( r == S_OK, "cannot add test component: %d\n", r );
1037
1038     r = create_feature_table( hdb );
1039     ok( r == S_OK, "cannot create Feature table: %d\n", r );
1040
1041     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1042     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1043
1044     r = create_feature_components_table( hdb );
1045     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1046
1047     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1048     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1049
1050     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1051     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1052
1053     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1054     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1055
1056     r = create_file_table( hdb );
1057     ok( r == S_OK, "cannot create File table: %d\n", r );
1058
1059     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1060     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1061
1062     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1063     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1064
1065     r = package_from_db( hdb, &hpkg );
1066     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1067     {
1068         skip("Not enough rights to perform tests\n");
1069         DeleteFile(msifile);
1070         return;
1071     }
1072     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1073
1074     r = MsiDoAction( hpkg, "CostInitialize");
1075     ok( r == ERROR_SUCCESS, "cost init failed\n");
1076
1077     r = MsiDoAction( hpkg, "FileCost");
1078     ok( r == ERROR_SUCCESS, "file cost failed\n");
1079
1080     r = MsiDoAction( hpkg, "CostFinalize");
1081     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1082
1083     r = MsiSetTargetPath( 0, NULL, NULL );
1084     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1085
1086     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1087     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1088
1089     r = MsiSetTargetPath( hpkg, "boo", NULL );
1090     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1091
1092     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1093     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1094
1095     sz = sizeof tempdir - 1;
1096     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1097     sprintf( file, "%srootfile.txt", tempdir );
1098     buffer[0] = 0;
1099     query_file_path( hpkg, "[#RootFile]", buffer );
1100     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1101     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1102
1103     GetTempFileName( tempdir, "_wt", 0, buffer );
1104     sprintf( tempdir, "%s\\subdir", buffer );
1105
1106     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1107     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1108         "MsiSetTargetPath on file returned %d\n", r );
1109
1110     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1111     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1112         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1113
1114     DeleteFile( buffer );
1115
1116     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1117     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1118
1119     r = GetFileAttributes( buffer );
1120     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1121
1122     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1123     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1124
1125     sz = sizeof buffer - 1;
1126     lstrcat( tempdir, "\\" );
1127     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1128     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1129     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1130
1131     sprintf( file, "%srootfile.txt", tempdir );
1132     query_file_path( hpkg, "[#RootFile]", buffer );
1133     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1134
1135     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1136     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1137
1138     query_file_path( hpkg, "[#TestFile]", buffer );
1139     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1140         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1141
1142     sz = sizeof buffer - 1;
1143     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1144     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1145     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1146
1147     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1148     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1149
1150     sz = sizeof buffer - 1;
1151     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1152     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1153     ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1154
1155     MsiCloseHandle( hpkg );
1156 }
1157
1158 static void test_condition(void)
1159 {
1160     MSICONDITION r;
1161     MSIHANDLE hpkg;
1162
1163     r = package_from_db(create_package_db(), &hpkg);
1164     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1165     {
1166         skip("Not enough rights to perform tests\n");
1167         DeleteFile(msifile);
1168         return;
1169     }
1170     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1171
1172     r = MsiEvaluateCondition(0, NULL);
1173     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1174
1175     r = MsiEvaluateCondition(hpkg, NULL);
1176     ok( r == MSICONDITION_NONE, "wrong return val\n");
1177
1178     r = MsiEvaluateCondition(hpkg, "");
1179     ok( r == MSICONDITION_NONE, "wrong return val\n");
1180
1181     r = MsiEvaluateCondition(hpkg, "1");
1182     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1183
1184     r = MsiEvaluateCondition(hpkg, "0");
1185     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1186
1187     r = MsiEvaluateCondition(hpkg, "-1");
1188     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1189
1190     r = MsiEvaluateCondition(hpkg, "0 = 0");
1191     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1192
1193     r = MsiEvaluateCondition(hpkg, "0 <> 0");
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, "0 ~> 1");
1203     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1204
1205     r = MsiEvaluateCondition(hpkg, "1 > 1");
1206     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1207
1208     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1209     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1210
1211     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1212     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1213
1214     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1215     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1216
1217     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1218     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1219
1220     r = MsiEvaluateCondition(hpkg, "1 ~>= 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, "0 ~< 1");
1227     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1228
1229     r = MsiEvaluateCondition(hpkg, "1 < 1");
1230     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1231
1232     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1233     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1234
1235     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1236     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1237
1238     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1239     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1240
1241     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1242     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1243
1244     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1245     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1246
1247     r = MsiEvaluateCondition(hpkg, "0 >=");
1248     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1249
1250     r = MsiEvaluateCondition(hpkg, " ");
1251     ok( r == MSICONDITION_NONE, "wrong return val\n");
1252
1253     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1254     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1255
1256     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1257     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258
1259     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1260     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "not 0");
1263     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, "not LicView");
1266     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1269     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1272     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1275     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1278     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1281     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, "\"0\"");
1284     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, "1 and 2");
1287     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1290     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1293     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1296     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, "(0)");
1299     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1302     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1305     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1308     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1311     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1314     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1317     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1318
1319     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1320     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1321
1322     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1323     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1324
1325     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1326     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1327
1328     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1329     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1330
1331     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1332     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333
1334     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1335     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1336
1337     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1338     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1339
1340     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1341     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1342
1343     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1344     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345
1346     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1347     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1348
1349     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1350     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1351
1352     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1353     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1354
1355     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1356     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1357
1358     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1359     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1360
1361     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1362     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1363
1364     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1365     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1366
1367     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1368     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1369
1370     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1371     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1372
1373     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1374     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1375
1376     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1377     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1378
1379     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1380     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1381
1382     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1383     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1384
1385     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1386     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1387
1388     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1389     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1390
1391     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1392     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1393
1394     MsiSetProperty(hpkg, "mm", "5" );
1395
1396     r = MsiEvaluateCondition(hpkg, "mm = 5");
1397     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1398
1399     r = MsiEvaluateCondition(hpkg, "mm < 6");
1400     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1401
1402     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1403     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1404
1405     r = MsiEvaluateCondition(hpkg, "mm > 4");
1406     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1407
1408     r = MsiEvaluateCondition(hpkg, "mm < 12");
1409     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1410
1411     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1412     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1413
1414     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1415     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1416
1417     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1418     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1419
1420     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1421     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1422
1423     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1424     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1425
1426     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1427     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1430     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1431
1432     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1433     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1434
1435     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1436     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1437
1438     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1439     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1440
1441     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1442     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1445     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1446
1447     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1448     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1449
1450     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1451     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1452
1453     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1454     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1455
1456     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1457     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1458
1459     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1460     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1461
1462     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1463     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1464
1465     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 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     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1475     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1476
1477     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1478     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1479
1480     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1481     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1482
1483     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1484     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1485
1486     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1487     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488
1489     MsiSetProperty(hpkg, "bandalmael", "0" );
1490     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1491     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1492
1493     MsiSetProperty(hpkg, "bandalmael", "" );
1494     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1495     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1496
1497     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1498     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1499     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1500
1501     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1502     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1503     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1504
1505     MsiSetProperty(hpkg, "bandalmael", "0 " );
1506     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1507     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1508
1509     MsiSetProperty(hpkg, "bandalmael", "-0" );
1510     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1511     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1512
1513     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1514     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1515     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1516
1517     MsiSetProperty(hpkg, "bandalmael", "--0" );
1518     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1519     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1520
1521     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1522     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1523     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1524
1525     MsiSetProperty(hpkg, "bandalmael", "-" );
1526     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1527     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1528
1529     MsiSetProperty(hpkg, "bandalmael", "+0" );
1530     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1531     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1532
1533     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1534     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1535     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1536     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1537     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1538
1539     MsiSetProperty(hpkg, "one", "hi");
1540     MsiSetProperty(hpkg, "two", "hithere");
1541     r = MsiEvaluateCondition(hpkg, "one >< two");
1542     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1543
1544     MsiSetProperty(hpkg, "one", "hithere");
1545     MsiSetProperty(hpkg, "two", "hi");
1546     r = MsiEvaluateCondition(hpkg, "one >< two");
1547     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1548
1549     MsiSetProperty(hpkg, "one", "hello");
1550     MsiSetProperty(hpkg, "two", "hi");
1551     r = MsiEvaluateCondition(hpkg, "one >< two");
1552     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1553
1554     MsiSetProperty(hpkg, "one", "hellohithere");
1555     MsiSetProperty(hpkg, "two", "hi");
1556     r = MsiEvaluateCondition(hpkg, "one >< two");
1557     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1558
1559     MsiSetProperty(hpkg, "one", "");
1560     MsiSetProperty(hpkg, "two", "hi");
1561     r = MsiEvaluateCondition(hpkg, "one >< two");
1562     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1563
1564     MsiSetProperty(hpkg, "one", "hi");
1565     MsiSetProperty(hpkg, "two", "");
1566     r = MsiEvaluateCondition(hpkg, "one >< two");
1567     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1568
1569     MsiSetProperty(hpkg, "one", "");
1570     MsiSetProperty(hpkg, "two", "");
1571     r = MsiEvaluateCondition(hpkg, "one >< two");
1572     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1573
1574     MsiSetProperty(hpkg, "one", "1234");
1575     MsiSetProperty(hpkg, "two", "1");
1576     r = MsiEvaluateCondition(hpkg, "one >< two");
1577     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1578
1579     MsiSetProperty(hpkg, "one", "one 1234");
1580     MsiSetProperty(hpkg, "two", "1");
1581     r = MsiEvaluateCondition(hpkg, "one >< two");
1582     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1583
1584     MsiSetProperty(hpkg, "one", "hithere");
1585     MsiSetProperty(hpkg, "two", "hi");
1586     r = MsiEvaluateCondition(hpkg, "one << two");
1587     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1588
1589     MsiSetProperty(hpkg, "one", "hi");
1590     MsiSetProperty(hpkg, "two", "hithere");
1591     r = MsiEvaluateCondition(hpkg, "one << two");
1592     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1593
1594     MsiSetProperty(hpkg, "one", "hi");
1595     MsiSetProperty(hpkg, "two", "hi");
1596     r = MsiEvaluateCondition(hpkg, "one << two");
1597     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1598
1599     MsiSetProperty(hpkg, "one", "abcdhithere");
1600     MsiSetProperty(hpkg, "two", "hi");
1601     r = MsiEvaluateCondition(hpkg, "one << two");
1602     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1603
1604     MsiSetProperty(hpkg, "one", "");
1605     MsiSetProperty(hpkg, "two", "hi");
1606     r = MsiEvaluateCondition(hpkg, "one << two");
1607     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1608
1609     MsiSetProperty(hpkg, "one", "hithere");
1610     MsiSetProperty(hpkg, "two", "");
1611     r = MsiEvaluateCondition(hpkg, "one << two");
1612     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1613
1614     MsiSetProperty(hpkg, "one", "");
1615     MsiSetProperty(hpkg, "two", "");
1616     r = MsiEvaluateCondition(hpkg, "one << two");
1617     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1618
1619     MsiSetProperty(hpkg, "one", "1234");
1620     MsiSetProperty(hpkg, "two", "1");
1621     r = MsiEvaluateCondition(hpkg, "one << two");
1622     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1623
1624     MsiSetProperty(hpkg, "one", "1234 one");
1625     MsiSetProperty(hpkg, "two", "1");
1626     r = MsiEvaluateCondition(hpkg, "one << two");
1627     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1628
1629     MsiSetProperty(hpkg, "one", "hithere");
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", "hithere");
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", "there");
1640     MsiSetProperty(hpkg, "two", "hithere");
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", "there");
1646     r = MsiEvaluateCondition(hpkg, "one >> two");
1647     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1648
1649     MsiSetProperty(hpkg, "one", "abcdhithere");
1650     MsiSetProperty(hpkg, "two", "hi");
1651     r = MsiEvaluateCondition(hpkg, "one >> two");
1652     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1653
1654     MsiSetProperty(hpkg, "one", "");
1655     MsiSetProperty(hpkg, "two", "there");
1656     r = MsiEvaluateCondition(hpkg, "one >> two");
1657     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1658
1659     MsiSetProperty(hpkg, "one", "there");
1660     MsiSetProperty(hpkg, "two", "");
1661     r = MsiEvaluateCondition(hpkg, "one >> two");
1662     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1663
1664     MsiSetProperty(hpkg, "one", "");
1665     MsiSetProperty(hpkg, "two", "");
1666     r = MsiEvaluateCondition(hpkg, "one >> two");
1667     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1668
1669     MsiSetProperty(hpkg, "one", "1234");
1670     MsiSetProperty(hpkg, "two", "4");
1671     r = MsiEvaluateCondition(hpkg, "one >> two");
1672     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1673
1674     MsiSetProperty(hpkg, "one", "one 1234");
1675     MsiSetProperty(hpkg, "two", "4");
1676     r = MsiEvaluateCondition(hpkg, "one >> two");
1677     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1678
1679     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
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 > \"1.1.4322\"");
1685     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1686
1687     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1688     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1689
1690     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1691     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1692
1693     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1694     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1695
1696     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1697     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1698
1699     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1700     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1701
1702     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1703     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1704
1705     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1706     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1707
1708     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1709     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1710
1711     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1712     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1713
1714     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1715     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1716
1717     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1718     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1719
1720     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1721     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1722
1723     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1724     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1725
1726     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1727     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1728
1729     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1730     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1731
1732     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1733     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1734
1735     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1736     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1737
1738     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1739     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1740
1741     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1742     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1743
1744     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1745     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1746
1747     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1748     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749
1750     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1751     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1752
1753     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1754     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1755
1756     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1757     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1758
1759     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1760     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1761
1762     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1763     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1764
1765     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]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]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     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1778     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1779
1780     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1781     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1782
1783     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1784     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1785
1786     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1787     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1788
1789     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1790     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1791
1792     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1793     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1794     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1795
1796     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1797     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1798
1799     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1800     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1801
1802     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1803     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1804
1805     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1806     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1807
1808     MsiSetProperty(hpkg, "one", "1");
1809     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1810     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1811
1812     MsiSetProperty(hpkg, "X", "5.0");
1813
1814     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1815     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1816
1817     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1818     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1819
1820     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1821     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1822
1823     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1824     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1825
1826     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1827     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1828
1829     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1830     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1831
1832     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1833     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1834
1835     /* feature doesn't exist */
1836     r = MsiEvaluateCondition(hpkg, "&nofeature");
1837     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1838
1839     MsiSetProperty(hpkg, "A", "2");
1840     MsiSetProperty(hpkg, "X", "50");
1841
1842     r = MsiEvaluateCondition(hpkg, "2 <= X");
1843     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1844
1845     r = MsiEvaluateCondition(hpkg, "A <= X");
1846     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1847
1848     r = MsiEvaluateCondition(hpkg, "A <= 50");
1849     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1850
1851     MsiSetProperty(hpkg, "X", "50val");
1852
1853     r = MsiEvaluateCondition(hpkg, "2 <= X");
1854     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1855
1856     r = MsiEvaluateCondition(hpkg, "A <= X");
1857     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1858
1859     MsiSetProperty(hpkg, "A", "7");
1860     MsiSetProperty(hpkg, "X", "50");
1861
1862     r = MsiEvaluateCondition(hpkg, "7 <= X");
1863     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1864
1865     r = MsiEvaluateCondition(hpkg, "A <= X");
1866     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1867
1868     r = MsiEvaluateCondition(hpkg, "A <= 50");
1869     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1870
1871     MsiSetProperty(hpkg, "X", "50val");
1872
1873     r = MsiEvaluateCondition(hpkg, "2 <= X");
1874     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1875
1876     r = MsiEvaluateCondition(hpkg, "A <= X");
1877     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1878
1879     MsiCloseHandle( hpkg );
1880     DeleteFile(msifile);
1881 }
1882
1883 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1884 {
1885     UINT r;
1886     DWORD sz;
1887     char buffer[2];
1888
1889     sz = sizeof buffer;
1890     strcpy(buffer,"x");
1891     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1892     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1893 }
1894
1895 static void test_props(void)
1896 {
1897     MSIHANDLE hpkg, hdb;
1898     UINT r;
1899     DWORD sz;
1900     char buffer[0x100];
1901
1902     hdb = create_package_db();
1903     r = run_query( hdb,
1904             "CREATE TABLE `Property` ( "
1905             "`Property` CHAR(255) NOT NULL, "
1906             "`Value` CHAR(255) "
1907             "PRIMARY KEY `Property`)" );
1908     ok( r == ERROR_SUCCESS , "Failed\n" );
1909
1910     r = run_query(hdb,
1911             "INSERT INTO `Property` "
1912             "(`Property`, `Value`) "
1913             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1914     ok( r == ERROR_SUCCESS , "Failed\n" );
1915
1916     r = package_from_db( hdb, &hpkg );
1917     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1918     {
1919         skip("Not enough rights to perform tests\n");
1920         DeleteFile(msifile);
1921         return;
1922     }
1923     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1924
1925     /* test invalid values */
1926     r = MsiGetProperty( 0, NULL, NULL, NULL );
1927     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1928
1929     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1930     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1931
1932     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1933     ok( r == ERROR_SUCCESS, "wrong return val\n");
1934
1935     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1936     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1937
1938     /* test retrieving an empty/nonexistent property */
1939     sz = sizeof buffer;
1940     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1941     ok( r == ERROR_SUCCESS, "wrong return val\n");
1942     ok( sz == 0, "wrong size returned\n");
1943
1944     check_prop_empty( hpkg, "boo");
1945     sz = 0;
1946     strcpy(buffer,"x");
1947     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1948     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1949     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1950     ok( sz == 0, "wrong size returned\n");
1951
1952     sz = 1;
1953     strcpy(buffer,"x");
1954     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1955     ok( r == ERROR_SUCCESS, "wrong return val\n");
1956     ok( buffer[0] == 0, "buffer was not changed\n");
1957     ok( sz == 0, "wrong size returned\n");
1958
1959     /* set the property to something */
1960     r = MsiSetProperty( 0, NULL, NULL );
1961     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1962
1963     r = MsiSetProperty( hpkg, NULL, NULL );
1964     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1965
1966     r = MsiSetProperty( hpkg, "", NULL );
1967     ok( r == ERROR_SUCCESS, "wrong return val\n");
1968
1969     /* try set and get some illegal property identifiers */
1970     r = MsiSetProperty( hpkg, "", "asdf" );
1971     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1972
1973     r = MsiSetProperty( hpkg, "=", "asdf" );
1974     ok( r == ERROR_SUCCESS, "wrong return val\n");
1975
1976     r = MsiSetProperty( hpkg, " ", "asdf" );
1977     ok( r == ERROR_SUCCESS, "wrong return val\n");
1978
1979     r = MsiSetProperty( hpkg, "'", "asdf" );
1980     ok( r == ERROR_SUCCESS, "wrong return val\n");
1981
1982     sz = sizeof buffer;
1983     buffer[0]=0;
1984     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1985     ok( r == ERROR_SUCCESS, "wrong return val\n");
1986     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1987
1988     /* set empty values */
1989     r = MsiSetProperty( hpkg, "boo", NULL );
1990     ok( r == ERROR_SUCCESS, "wrong return val\n");
1991     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1992
1993     r = MsiSetProperty( hpkg, "boo", "" );
1994     ok( r == ERROR_SUCCESS, "wrong return val\n");
1995     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1996
1997     /* set a non-empty value */
1998     r = MsiSetProperty( hpkg, "boo", "xyz" );
1999     ok( r == ERROR_SUCCESS, "wrong return val\n");
2000
2001     sz = 1;
2002     strcpy(buffer,"x");
2003     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2004     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2005     ok( buffer[0] == 0, "buffer was not changed\n");
2006     ok( sz == 3, "wrong size returned\n");
2007
2008     sz = 4;
2009     strcpy(buffer,"x");
2010     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2011     ok( r == ERROR_SUCCESS, "wrong return val\n");
2012     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2013     ok( sz == 3, "wrong size returned\n");
2014
2015     sz = 3;
2016     strcpy(buffer,"x");
2017     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2018     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2019     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2020     ok( sz == 3, "wrong size returned\n");
2021
2022     r = MsiSetProperty(hpkg, "SourceDir", "foo");
2023     ok( r == ERROR_SUCCESS, "wrong return val\n");
2024
2025     sz = 4;
2026     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2027     ok( r == ERROR_SUCCESS, "wrong return val\n");
2028     ok( !strcmp(buffer,""), "buffer wrong\n");
2029     ok( sz == 0, "wrong size returned\n");
2030
2031     sz = 4;
2032     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2033     ok( r == ERROR_SUCCESS, "wrong return val\n");
2034     ok( !strcmp(buffer,""), "buffer wrong\n");
2035     ok( sz == 0, "wrong size returned\n");
2036
2037     sz = 4;
2038     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2039     ok( r == ERROR_SUCCESS, "wrong return val\n");
2040     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2041     ok( sz == 3, "wrong size returned\n");
2042
2043     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2044     ok( r == ERROR_SUCCESS, "wrong return val\n");
2045
2046     sz = 0;
2047     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2048     ok( r == ERROR_SUCCESS, "return wrong\n");
2049     ok( sz == 13, "size wrong (%d)\n", sz);
2050
2051     sz = 13;
2052     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2053     ok( r == ERROR_MORE_DATA, "return wrong\n");
2054     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2055
2056     r = MsiSetProperty(hpkg, "property", "value");
2057     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2058
2059     sz = 6;
2060     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2061     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2062     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2063
2064     r = MsiSetProperty(hpkg, "property", NULL);
2065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2066
2067     sz = 6;
2068     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2069     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2070     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2071
2072     MsiCloseHandle( hpkg );
2073     DeleteFile(msifile);
2074 }
2075
2076 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2077 {
2078     MSIHANDLE hview, hrec;
2079     BOOL found;
2080     CHAR buffer[MAX_PATH];
2081     DWORD sz;
2082     UINT r;
2083
2084     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2085     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2086     r = MsiViewExecute(hview, 0);
2087     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2088
2089     found = FALSE;
2090     while (r == ERROR_SUCCESS && !found)
2091     {
2092         r = MsiViewFetch(hview, &hrec);
2093         if (r != ERROR_SUCCESS) break;
2094
2095         sz = MAX_PATH;
2096         r = MsiRecordGetString(hrec, 1, buffer, &sz);
2097         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2098         {
2099             sz = MAX_PATH;
2100             r = MsiRecordGetString(hrec, 2, buffer, &sz);
2101             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2102                 found = TRUE;
2103         }
2104
2105         MsiCloseHandle(hrec);
2106     }
2107
2108     MsiViewClose(hview);
2109     MsiCloseHandle(hview);
2110
2111     return found;
2112 }
2113
2114 static void test_property_table(void)
2115 {
2116     const char *query;
2117     UINT r;
2118     MSIHANDLE hpkg, hdb, hrec;
2119     char buffer[MAX_PATH], package[10];
2120     DWORD sz;
2121     BOOL found;
2122
2123     hdb = create_package_db();
2124     ok( hdb, "failed to create package\n");
2125
2126     r = package_from_db(hdb, &hpkg);
2127     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2128     {
2129         skip("Not enough rights to perform tests\n");
2130         DeleteFile(msifile);
2131         return;
2132     }
2133     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2134
2135     MsiCloseHandle(hdb);
2136
2137     hdb = MsiGetActiveDatabase(hpkg);
2138
2139     query = "CREATE TABLE `_Property` ( "
2140         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2141     r = run_query(hdb, query);
2142     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2143
2144     MsiCloseHandle(hdb);
2145     MsiCloseHandle(hpkg);
2146     DeleteFile(msifile);
2147
2148     hdb = create_package_db();
2149     ok( hdb, "failed to create package\n");
2150
2151     query = "CREATE TABLE `_Property` ( "
2152         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2153     r = run_query(hdb, query);
2154     ok(r == ERROR_SUCCESS, "failed to create table\n");
2155
2156     query = "ALTER `_Property` ADD `foo` INTEGER";
2157     r = run_query(hdb, query);
2158     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2159
2160     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2161     r = run_query(hdb, query);
2162     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2163
2164     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2165     r = run_query(hdb, query);
2166     ok(r == ERROR_SUCCESS, "failed to add column\n");
2167
2168     sprintf(package, "#%i", hdb);
2169     r = MsiOpenPackage(package, &hpkg);
2170     todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2171     if (r == ERROR_SUCCESS)
2172         MsiCloseHandle(hpkg);
2173
2174     r = MsiCloseHandle(hdb);
2175     ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2176
2177     hdb = create_package_db();
2178     ok (hdb, "failed to create package database\n");
2179
2180     r = create_property_table(hdb);
2181     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2182
2183     r = add_property_entry(hdb, "'prop', 'val'");
2184     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2185
2186     r = package_from_db(hdb, &hpkg);
2187     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2188
2189     MsiCloseHandle(hdb);
2190
2191     sz = MAX_PATH;
2192     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2193     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2194     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2195
2196     hdb = MsiGetActiveDatabase(hpkg);
2197
2198     found = find_prop_in_property(hdb, "prop", "val");
2199     ok(found, "prop should be in the _Property table\n");
2200
2201     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2202     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2203
2204     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2205     r = do_query(hdb, query, &hrec);
2206     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2207
2208     found = find_prop_in_property(hdb, "dantes", "mercedes");
2209     ok(found == FALSE, "dantes should not be in the _Property table\n");
2210
2211     sz = MAX_PATH;
2212     lstrcpy(buffer, "aaa");
2213     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2214     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2215     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2216
2217     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2218     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2219
2220     found = find_prop_in_property(hdb, "dantes", "mercedes");
2221     ok(found == TRUE, "dantes should be in the _Property table\n");
2222
2223     MsiCloseHandle(hdb);
2224     MsiCloseHandle(hpkg);
2225     DeleteFile(msifile);
2226 }
2227
2228 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2229 {
2230     MSIHANDLE htab = 0;
2231     UINT res;
2232
2233     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2234     if( res == ERROR_SUCCESS )
2235     {
2236         UINT r;
2237
2238         r = MsiViewExecute( htab, hrec );
2239         if( r != ERROR_SUCCESS )
2240         {
2241             res = r;
2242             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2243         }
2244
2245         r = MsiViewClose( htab );
2246         if( r != ERROR_SUCCESS )
2247             res = r;
2248
2249         r = MsiCloseHandle( htab );
2250         if( r != ERROR_SUCCESS )
2251             res = r;
2252     }
2253     return res;
2254 }
2255
2256 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2257 {
2258     return try_query_param( hdb, szQuery, 0 );
2259 }
2260
2261 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2262 {
2263     MSIHANDLE summary;
2264     UINT r;
2265
2266     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2267     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2268
2269     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2270     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2271
2272     r = MsiSummaryInfoPersist(summary);
2273     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2274
2275     MsiCloseHandle(summary);
2276 }
2277
2278 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2279 {
2280     MSIHANDLE summary;
2281     UINT r;
2282
2283     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2284     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2285
2286     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2288
2289     r = MsiSummaryInfoPersist(summary);
2290     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2291
2292     MsiCloseHandle(summary);
2293 }
2294
2295 static void test_msipackage(void)
2296 {
2297     MSIHANDLE hdb = 0, hpack = 100;
2298     UINT r;
2299     const char *query;
2300     char name[10];
2301
2302     /* NULL szPackagePath */
2303     r = MsiOpenPackage(NULL, &hpack);
2304     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2305
2306     /* empty szPackagePath */
2307     r = MsiOpenPackage("", &hpack);
2308     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2309     {
2310         skip("Not enough rights to perform tests\n");
2311         return;
2312     }
2313     todo_wine
2314     {
2315         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2316     }
2317
2318     if (r == ERROR_SUCCESS)
2319         MsiCloseHandle(hpack);
2320
2321     /* nonexistent szPackagePath */
2322     r = MsiOpenPackage("nonexistent", &hpack);
2323     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2324
2325     /* NULL hProduct */
2326     r = MsiOpenPackage(msifile, NULL);
2327     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2328
2329     name[0]='#';
2330     name[1]=0;
2331     r = MsiOpenPackage(name, &hpack);
2332     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2333
2334     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2335     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2336
2337     /* database exists, but is emtpy */
2338     sprintf(name, "#%d", hdb);
2339     r = MsiOpenPackage(name, &hpack);
2340     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2341        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2342
2343     query = "CREATE TABLE `Property` ( "
2344             "`Property` CHAR(72), `Value` CHAR(0) "
2345             "PRIMARY KEY `Property`)";
2346     r = try_query(hdb, query);
2347     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2348
2349     query = "CREATE TABLE `InstallExecuteSequence` ("
2350             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2351             "PRIMARY KEY `Action`)";
2352     r = try_query(hdb, query);
2353     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2354
2355     /* a few key tables exist */
2356     sprintf(name, "#%d", hdb);
2357     r = MsiOpenPackage(name, &hpack);
2358     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2359        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2360
2361     MsiCloseHandle(hdb);
2362     DeleteFile(msifile);
2363
2364     /* start with a clean database to show what constitutes a valid package */
2365     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2366     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2367
2368     sprintf(name, "#%d", hdb);
2369
2370     /* The following summary information props must exist:
2371      *  - PID_REVNUMBER
2372      *  - PID_PAGECOUNT
2373      */
2374
2375     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2376     r = MsiOpenPackage(name, &hpack);
2377     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2378        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2379
2380     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2381     r = MsiOpenPackage(name, &hpack);
2382     ok(r == ERROR_SUCCESS,
2383        "Expected ERROR_SUCCESS, got %d\n", r);
2384
2385     MsiCloseHandle(hpack);
2386     MsiCloseHandle(hdb);
2387     DeleteFile(msifile);
2388 }
2389
2390 static void test_formatrecord2(void)
2391 {
2392     MSIHANDLE hpkg, hrec ;
2393     char buffer[0x100];
2394     DWORD sz;
2395     UINT r;
2396
2397     r = package_from_db(create_package_db(), &hpkg);
2398     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2399     {
2400         skip("Not enough rights to perform tests\n");
2401         DeleteFile(msifile);
2402         return;
2403     }
2404     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2405
2406     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2407     ok( r == ERROR_SUCCESS, "set property failed\n");
2408
2409     hrec = MsiCreateRecord(2);
2410     ok(hrec, "create record failed\n");
2411
2412     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2413     ok( r == ERROR_SUCCESS, "format record failed\n");
2414
2415     buffer[0] = 0;
2416     sz = sizeof buffer;
2417     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
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, "x[~]x");
2428     sz = sizeof buffer;
2429     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2430     ok( sz == 3, "size wrong\n");
2431     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2432     ok( r == ERROR_SUCCESS, "format failed\n");
2433
2434     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2435     r = MsiRecordSetString(hrec, 1, "hoo");
2436     sz = sizeof buffer;
2437     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2438     ok( sz == 3, "size wrong\n");
2439     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2440     ok( r == ERROR_SUCCESS, "format failed\n");
2441
2442     r = MsiRecordSetString(hrec, 0, "[\\[]");
2443     sz = sizeof buffer;
2444     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2445     ok( sz == 1, "size wrong\n");
2446     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2447     ok( r == ERROR_SUCCESS, "format failed\n");
2448
2449     SetEnvironmentVariable("FOO", "BAR");
2450     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2451     sz = sizeof buffer;
2452     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2453     ok( sz == 3, "size wrong\n");
2454     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2455     ok( r == ERROR_SUCCESS, "format failed\n");
2456
2457     r = MsiRecordSetString(hrec, 0, "[[1]]");
2458     r = MsiRecordSetString(hrec, 1, "%FOO");
2459     sz = sizeof buffer;
2460     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2461     ok( sz == 3, "size wrong\n");
2462     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2463     ok( r == ERROR_SUCCESS, "format failed\n");
2464
2465     MsiCloseHandle( hrec );
2466     MsiCloseHandle( hpkg );
2467     DeleteFile(msifile);
2468 }
2469
2470 static void test_states(void)
2471 {
2472     MSIHANDLE hpkg;
2473     UINT r;
2474     MSIHANDLE hdb;
2475     INSTALLSTATE state, action;
2476
2477     static const CHAR msifile2[] = "winetest2-package.msi";
2478     static const CHAR msifile3[] = "winetest3-package.msi";
2479     static const CHAR msifile4[] = "winetest4-package.msi";
2480
2481     if (is_process_limited())
2482     {
2483         skip("process is limited\n");
2484         return;
2485     }
2486
2487     hdb = create_package_db();
2488     ok ( hdb, "failed to create package database\n" );
2489
2490     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2491     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2492
2493     r = create_property_table( hdb );
2494     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2495
2496     r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2497     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2498
2499     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2500     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2501
2502     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2503     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2504
2505     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2506     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2507
2508     r = create_install_execute_sequence_table( hdb );
2509     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2510
2511     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2512     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2513
2514     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2515     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2516
2517     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2518     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2519
2520     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2521     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2522
2523     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2524     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2525
2526     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2527     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2528
2529     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2530     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2531
2532     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2533     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2534
2535     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2536     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2537
2538     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2539     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2540
2541     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2542     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2543
2544     r = create_media_table( hdb );
2545     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2546
2547     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2548     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2549
2550     r = create_feature_table( hdb );
2551     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2552
2553     r = create_component_table( hdb );
2554     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2555
2556     /* msidbFeatureAttributesFavorLocal */
2557     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2558     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2559
2560     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2561     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2562     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2563
2564     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2565     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2566     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2567
2568     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2569     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2570     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2571
2572     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2573     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2574     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2575
2576     /* msidbFeatureAttributesFavorSource */
2577     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2578     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2579
2580     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2581     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2582     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2583
2584     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2585     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2586     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2587
2588     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2589     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2590     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2591
2592     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2593     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2594     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2595
2596     /* msidbFeatureAttributesFavorSource */
2597     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2598     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2599
2600     /* msidbFeatureAttributesFavorLocal */
2601     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2602     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2603
2604     /* disabled */
2605     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2606     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2607
2608     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2609     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2610     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2611
2612     /* no feature parent:msidbComponentAttributesLocalOnly */
2613     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2614     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2615
2616     /* msidbFeatureAttributesFavorLocal:removed */
2617     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2618     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2619
2620     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2621     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2622     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2623
2624     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2625     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2626     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2627
2628     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2629     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2630     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2631
2632     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2633     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2634     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2635
2636     /* msidbFeatureAttributesFavorSource:removed */
2637     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2638     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2639
2640     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2641     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2642     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2643
2644     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2645     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2646     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2647
2648     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2649     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2650     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2651
2652     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2653     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2654     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2655
2656     /* msidbFeatureAttributesFavorLocal */
2657     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2658     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2659
2660     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2661     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2662
2663     /* msidbFeatureAttributesFavorSource */
2664     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2665     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2666
2667     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2668     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2669
2670     /* msidbFeatureAttributesFavorAdvertise */
2671     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2672     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2673
2674     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2675     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2676
2677     r = create_feature_components_table( hdb );
2678     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2679
2680     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2681     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2682
2683     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2684     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2685
2686     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2687     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2688
2689     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2690     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2691
2692     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2693     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2694
2695     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2696     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2697
2698     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2699     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2700
2701     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2702     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2703
2704     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2705     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2706
2707     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2708     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2709
2710     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2711     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2712
2713     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2714     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2715
2716     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2717     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2718
2719     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2720     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2721
2722     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2723     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2724
2725     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2726     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2727
2728     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2729     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2730
2731     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2732     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2733
2734     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2735     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2736
2737     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2738     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2739
2740     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2741     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2742
2743     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2744     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2745
2746     r = create_file_table( hdb );
2747     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2748
2749     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2750     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2751
2752     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2753     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2754
2755     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2756     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2757
2758     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2759     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2760
2761     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2762     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2763
2764     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2765     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2766
2767     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2768     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2769
2770     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2771     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2772
2773     /* compressed file */
2774     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2775     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2776
2777     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2778     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2779
2780     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2781     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2782
2783     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2784     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2785
2786     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2787     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2788
2789     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2790     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2791
2792     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2793     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2794
2795     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2796     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2797
2798     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2799     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2800
2801     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2802     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2803
2804     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2805     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2806
2807     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2808     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2809
2810     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2811     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2812
2813     MsiDatabaseCommit(hdb);
2814
2815     /* these properties must not be in the saved msi file */
2816     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2817     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2818
2819     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2820     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2821
2822     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2823     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2824
2825     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2826     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2827
2828     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2829     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2830
2831     r = package_from_db( hdb, &hpkg );
2832     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2833     {
2834         skip("Not enough rights to perform tests\n");
2835         DeleteFile(msifile);
2836         return;
2837     }
2838     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2839
2840     MsiCloseHandle(hdb);
2841
2842     CopyFileA(msifile, msifile2, FALSE);
2843     CopyFileA(msifile, msifile3, FALSE);
2844     CopyFileA(msifile, msifile4, FALSE);
2845
2846     state = 0xdeadbee;
2847     action = 0xdeadbee;
2848     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2849     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2850     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2851     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2852
2853     state = 0xdeadbee;
2854     action = 0xdeadbee;
2855     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2856     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2857     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2858     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2859
2860     state = 0xdeadbee;
2861     action = 0xdeadbee;
2862     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2863     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2864     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2865     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2866
2867     state = 0xdeadbee;
2868     action = 0xdeadbee;
2869     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2870     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2871     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2872     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2873
2874     state = 0xdeadbee;
2875     action = 0xdeadbee;
2876     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2877     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2878     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2879     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2880
2881     state = 0xdeadbee;
2882     action = 0xdeadbee;
2883     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2884     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2885     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2886     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2887
2888     state = 0xdeadbee;
2889     action = 0xdeadbee;
2890     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2891     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2892     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2893     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2894
2895     state = 0xdeadbee;
2896     action = 0xdeadbee;
2897     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2898     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2899     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2900     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2901
2902     state = 0xdeadbee;
2903     action = 0xdeadbee;
2904     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2905     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2906     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2907     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2908
2909     state = 0xdeadbee;
2910     action = 0xdeadbee;
2911     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2912     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2913     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2914     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2915
2916     state = 0xdeadbee;
2917     action = 0xdeadbee;
2918     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2919     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2920     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2921     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2922
2923     state = 0xdeadbee;
2924     action = 0xdeadbee;
2925     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2926     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2927     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2928     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2929
2930     state = 0xdeadbee;
2931     action = 0xdeadbee;
2932     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2933     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2934     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2935     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2936
2937     state = 0xdeadbee;
2938     action = 0xdeadbee;
2939     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2940     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2941     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2942     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2943
2944     state = 0xdeadbee;
2945     action = 0xdeadbee;
2946     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2947     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2948     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2949     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2950
2951     state = 0xdeadbee;
2952     action = 0xdeadbee;
2953     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2954     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2955     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2956     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2957
2958     state = 0xdeadbee;
2959     action = 0xdeadbee;
2960     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2961     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2962     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2963     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2964
2965     state = 0xdeadbee;
2966     action = 0xdeadbee;
2967     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2968     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2969     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2970     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2971
2972     state = 0xdeadbee;
2973     action = 0xdeadbee;
2974     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2975     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2976     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2977     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2978
2979     state = 0xdeadbee;
2980     action = 0xdeadbee;
2981     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2982     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2983     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2984     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2985
2986     state = 0xdeadbee;
2987     action = 0xdeadbee;
2988     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2989     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2990     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2991     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2992
2993     state = 0xdeadbee;
2994     action = 0xdeadbee;
2995     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2996     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2997     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2998     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2999
3000     state = 0xdeadbee;
3001     action = 0xdeadbee;
3002     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3003     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3004     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3005     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3006
3007     state = 0xdeadbee;
3008     action = 0xdeadbee;
3009     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3010     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3011     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3012     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3013
3014     state = 0xdeadbee;
3015     action = 0xdeadbee;
3016     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3017     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3018     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3019     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3020
3021     state = 0xdeadbee;
3022     action = 0xdeadbee;
3023     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3024     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3025     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3026     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3027
3028     state = 0xdeadbee;
3029     action = 0xdeadbee;
3030     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3031     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3032     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3033     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3034
3035     state = 0xdeadbee;
3036     action = 0xdeadbee;
3037     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3038     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3039     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3040     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3041
3042     state = 0xdeadbee;
3043     action = 0xdeadbee;
3044     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3045     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3046     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3047     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3048
3049     state = 0xdeadbee;
3050     action = 0xdeadbee;
3051     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3052     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3053     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3054     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3055
3056     state = 0xdeadbee;
3057     action = 0xdeadbee;
3058     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3059     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3060     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3061     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3062
3063     r = MsiDoAction( hpkg, "CostInitialize");
3064     ok( r == ERROR_SUCCESS, "cost init failed\n");
3065
3066     state = 0xdeadbee;
3067     action = 0xdeadbee;
3068     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3069     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3070     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3071     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3072
3073     state = 0xdeadbee;
3074     action = 0xdeadbee;
3075     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3076     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3077     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3078     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3079
3080     state = 0xdeadbee;
3081     action = 0xdeadbee;
3082     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3083     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3084     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3085     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3086
3087     state = 0xdeadbee;
3088     action = 0xdeadbee;
3089     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3090     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3091     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3092     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3093
3094     state = 0xdeadbee;
3095     action = 0xdeadbee;
3096     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3097     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3098     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3099     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3100
3101     state = 0xdeadbee;
3102     action = 0xdeadbee;
3103     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3104     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3105     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3106     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3107
3108     state = 0xdeadbee;
3109     action = 0xdeadbee;
3110     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3111     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3112     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3113     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3114
3115     state = 0xdeadbee;
3116     action = 0xdeadbee;
3117     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3118     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3119     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3120     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3121
3122     state = 0xdeadbee;
3123     action = 0xdeadbee;
3124     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3125     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3126     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3127     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3128
3129     state = 0xdeadbee;
3130     action = 0xdeadbee;
3131     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3132     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3133     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3134     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3135
3136     state = 0xdeadbee;
3137     action = 0xdeadbee;
3138     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3139     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3140     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3141     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3142
3143     state = 0xdeadbee;
3144     action = 0xdeadbee;
3145     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3146     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3147     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3148     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3149
3150     state = 0xdeadbee;
3151     action = 0xdeadbee;
3152     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3153     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3154     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3155     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3156
3157     state = 0xdeadbee;
3158     action = 0xdeadbee;
3159     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3160     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3161     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3162     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3163
3164     state = 0xdeadbee;
3165     action = 0xdeadbee;
3166     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3167     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3168     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3169     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3170
3171     state = 0xdeadbee;
3172     action = 0xdeadbee;
3173     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3174     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3175     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3176     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3177
3178     state = 0xdeadbee;
3179     action = 0xdeadbee;
3180     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3181     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3182     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3183     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3184
3185     state = 0xdeadbee;
3186     action = 0xdeadbee;
3187     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3188     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3189     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3190     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3191
3192     state = 0xdeadbee;
3193     action = 0xdeadbee;
3194     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3195     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3196     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3197     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3198
3199     state = 0xdeadbee;
3200     action = 0xdeadbee;
3201     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3202     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3203     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3204     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3205
3206     state = 0xdeadbee;
3207     action = 0xdeadbee;
3208     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3209     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3210     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3211     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3212
3213     state = 0xdeadbee;
3214     action = 0xdeadbee;
3215     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3216     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3217     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3218     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3219
3220     state = 0xdeadbee;
3221     action = 0xdeadbee;
3222     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3223     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3224     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3225     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3226
3227     state = 0xdeadbee;
3228     action = 0xdeadbee;
3229     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3230     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3231     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3232     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3233
3234     state = 0xdeadbee;
3235     action = 0xdeadbee;
3236     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3237     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3238     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3239     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3240
3241     state = 0xdeadbee;
3242     action = 0xdeadbee;
3243     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3244     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3245     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3246     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3247
3248     state = 0xdeadbee;
3249     action = 0xdeadbee;
3250     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3251     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3252     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3253     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3254
3255     state = 0xdeadbee;
3256     action = 0xdeadbee;
3257     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3258     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3259     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3260     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3261
3262     state = 0xdeadbee;
3263     action = 0xdeadbee;
3264     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3265     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3266     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3267     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3268
3269     state = 0xdeadbee;
3270     action = 0xdeadbee;
3271     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3272     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3273     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3274     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3275
3276     state = 0xdeadbee;
3277     action = 0xdeadbee;
3278     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3279     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3280     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3281     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3282
3283     r = MsiDoAction( hpkg, "FileCost");
3284     ok( r == ERROR_SUCCESS, "file cost failed\n");
3285
3286     state = 0xdeadbee;
3287     action = 0xdeadbee;
3288     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3289     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3290     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3291     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3292
3293     state = 0xdeadbee;
3294     action = 0xdeadbee;
3295     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3296     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3297     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3298     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3299
3300     state = 0xdeadbee;
3301     action = 0xdeadbee;
3302     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3303     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3304     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3305     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3306
3307     state = 0xdeadbee;
3308     action = 0xdeadbee;
3309     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3310     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3311     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3312     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3313
3314     state = 0xdeadbee;
3315     action = 0xdeadbee;
3316     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3317     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3318     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3319     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3320
3321     state = 0xdeadbee;
3322     action = 0xdeadbee;
3323     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3324     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3325     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3326     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3327
3328     state = 0xdeadbee;
3329     action = 0xdeadbee;
3330     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3331     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3332     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3333     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3334
3335     state = 0xdeadbee;
3336     action = 0xdeadbee;
3337     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3338     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3339     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3340     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3341
3342     state = 0xdeadbee;
3343     action = 0xdeadbee;
3344     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3345     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3346     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3347     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3348
3349     state = 0xdeadbee;
3350     action = 0xdeadbee;
3351     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3352     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3353     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3354     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3355
3356     state = 0xdeadbee;
3357     action = 0xdeadbee;
3358     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3359     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3360     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3361     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3362
3363     state = 0xdeadbee;
3364     action = 0xdeadbee;
3365     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3366     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3367     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3368     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3369
3370     state = 0xdeadbee;
3371     action = 0xdeadbee;
3372     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3373     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3374     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3375     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3376
3377     state = 0xdeadbee;
3378     action = 0xdeadbee;
3379     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3380     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3381     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3382     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3383
3384     state = 0xdeadbee;
3385     action = 0xdeadbee;
3386     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3387     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3388     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3389     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3390
3391     state = 0xdeadbee;
3392     action = 0xdeadbee;
3393     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3394     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3395     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3396     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3397
3398     state = 0xdeadbee;
3399     action = 0xdeadbee;
3400     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3401     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3402     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3403     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3404
3405     state = 0xdeadbee;
3406     action = 0xdeadbee;
3407     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3408     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3409     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3410     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3411
3412     state = 0xdeadbee;
3413     action = 0xdeadbee;
3414     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3415     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3416     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3417     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3418
3419     state = 0xdeadbee;
3420     action = 0xdeadbee;
3421     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3422     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3423     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3424     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3425
3426     state = 0xdeadbee;
3427     action = 0xdeadbee;
3428     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3429     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3430     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3431     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3432
3433     state = 0xdeadbee;
3434     action = 0xdeadbee;
3435     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3436     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3437     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3438     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3439
3440     state = 0xdeadbee;
3441     action = 0xdeadbee;
3442     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3443     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3444     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3445     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3446
3447     state = 0xdeadbee;
3448     action = 0xdeadbee;
3449     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3450     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3451     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3452     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3453
3454     state = 0xdeadbee;
3455     action = 0xdeadbee;
3456     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3457     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3458     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3459     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3460
3461     state = 0xdeadbee;
3462     action = 0xdeadbee;
3463     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3464     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3465     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3466     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3467
3468     state = 0xdeadbee;
3469     action = 0xdeadbee;
3470     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3471     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3472     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3473     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3474
3475     state = 0xdeadbee;
3476     action = 0xdeadbee;
3477     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3478     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3479     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3480     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3481
3482     state = 0xdeadbee;
3483     action = 0xdeadbee;
3484     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3485     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3486     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3487     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3488
3489     state = 0xdeadbee;
3490     action = 0xdeadbee;
3491     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3492     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3493     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3494     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3495
3496     state = 0xdeadbee;
3497     action = 0xdeadbee;
3498     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3499     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3500     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3501     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3502
3503     r = MsiDoAction( hpkg, "CostFinalize");
3504     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3505
3506     state = 0xdeadbee;
3507     action = 0xdeadbee;
3508     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3509     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3510     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3511     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3512
3513     state = 0xdeadbee;
3514     action = 0xdeadbee;
3515     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3516     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3517     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3518     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3519
3520     state = 0xdeadbee;
3521     action = 0xdeadbee;
3522     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3523     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3524     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3525     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3526
3527     state = 0xdeadbee;
3528     action = 0xdeadbee;
3529     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3530     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3531     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3532     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3533
3534     state = 0xdeadbee;
3535     action = 0xdeadbee;
3536     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3537     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3538     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3539     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3540
3541     state = 0xdeadbee;
3542     action = 0xdeadbee;
3543     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3544     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3545     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3546     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3547
3548     state = 0xdeadbee;
3549     action = 0xdeadbee;
3550     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3551     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3552     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3553     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3554
3555     state = 0xdeadbee;
3556     action = 0xdeadbee;
3557     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3558     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3559     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3560     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3561
3562     state = 0xdeadbee;
3563     action = 0xdeadbee;
3564     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3565     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3566     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3567     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3568
3569     state = 0xdeadbee;
3570     action = 0xdeadbee;
3571     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3572     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3573     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3574     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3575
3576     state = 0xdeadbee;
3577     action = 0xdeadbee;
3578     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3579     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3580     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3581     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3582
3583     state = 0xdeadbee;
3584     action = 0xdeadbee;
3585     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3586     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3587     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3588     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3589
3590     state = 0xdeadbee;
3591     action = 0xdeadbee;
3592     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3593     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3594     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3595     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3596
3597     state = 0xdeadbee;
3598     action = 0xdeadbee;
3599     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3600     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3601     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3602     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3603
3604     state = 0xdeadbee;
3605     action = 0xdeadbee;
3606     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3607     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3608     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3609     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3610
3611     state = 0xdeadbee;
3612     action = 0xdeadbee;
3613     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3614     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3615     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3616     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3617
3618     state = 0xdeadbee;
3619     action = 0xdeadbee;
3620     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3621     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3622     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3623     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3624
3625     state = 0xdeadbee;
3626     action = 0xdeadbee;
3627     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3628     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3629     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3630     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3631
3632     state = 0xdeadbee;
3633     action = 0xdeadbee;
3634     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3635     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3636     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3637     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3638
3639     state = 0xdeadbee;
3640     action = 0xdeadbee;
3641     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3642     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3643     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3644     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3645
3646     state = 0xdeadbee;
3647     action = 0xdeadbee;
3648     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3649     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3650     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3651     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3652
3653     state = 0xdeadbee;
3654     action = 0xdeadbee;
3655     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3656     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3657     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3658     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3659
3660     state = 0xdeadbee;
3661     action = 0xdeadbee;
3662     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3663     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3664     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3665     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3666
3667     state = 0xdeadbee;
3668     action = 0xdeadbee;
3669     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3670     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3671     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3672     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3673
3674     state = 0xdeadbee;
3675     action = 0xdeadbee;
3676     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3677     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3678     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3679     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3680
3681     state = 0xdeadbee;
3682     action = 0xdeadbee;
3683     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3684     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3685     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3686     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3687
3688     state = 0xdeadbee;
3689     action = 0xdeadbee;
3690     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3691     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3692     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3693     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3694
3695     state = 0xdeadbee;
3696     action = 0xdeadbee;
3697     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3698     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3699     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3700     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3701
3702     state = 0xdeadbee;
3703     action = 0xdeadbee;
3704     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3705     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3706     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3707     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3708
3709     state = 0xdeadbee;
3710     action = 0xdeadbee;
3711     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3712     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3713     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3714     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3715
3716     state = 0xdeadbee;
3717     action = 0xdeadbee;
3718     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3719     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3720     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3721     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3722
3723     MsiCloseHandle( hpkg );
3724
3725     /* publish the features and components */
3726     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3727     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3728
3729     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3730     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3731
3732     /* these properties must not be in the saved msi file */
3733     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3734     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3735
3736     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3737     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3738
3739     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3740     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3741
3742     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3743     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3744
3745     r = package_from_db( hdb, &hpkg );
3746     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3747
3748     MsiCloseHandle(hdb);
3749
3750     state = 0xdeadbee;
3751     action = 0xdeadbee;
3752     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3753     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3754     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3755     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3756
3757     state = 0xdeadbee;
3758     action = 0xdeadbee;
3759     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3760     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3761     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3762     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3763
3764     state = 0xdeadbee;
3765     action = 0xdeadbee;
3766     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3767     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3768     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3769     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3770
3771     state = 0xdeadbee;
3772     action = 0xdeadbee;
3773     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3774     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3775     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3776     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3777
3778     state = 0xdeadbee;
3779     action = 0xdeadbee;
3780     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3781     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3782     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3783     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3784
3785     state = 0xdeadbee;
3786     action = 0xdeadbee;
3787     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3788     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3789     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3790     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3791
3792     state = 0xdeadbee;
3793     action = 0xdeadbee;
3794     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3795     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3796     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3797     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3798
3799     state = 0xdeadbee;
3800     action = 0xdeadbee;
3801     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3802     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3803     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3804     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3805
3806     state = 0xdeadbee;
3807     action = 0xdeadbee;
3808     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3809     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3810     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3811     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3812
3813     state = 0xdeadbee;
3814     action = 0xdeadbee;
3815     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3816     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3817     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3818     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3819
3820     state = 0xdeadbee;
3821     action = 0xdeadbee;
3822     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3823     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3824     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3825     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3826
3827     state = 0xdeadbee;
3828     action = 0xdeadbee;
3829     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3830     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3831     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3832     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3833
3834     state = 0xdeadbee;
3835     action = 0xdeadbee;
3836     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3837     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3838     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3839     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3840
3841     state = 0xdeadbee;
3842     action = 0xdeadbee;
3843     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3844     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3845     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3846     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3847
3848     state = 0xdeadbee;
3849     action = 0xdeadbee;
3850     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3851     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3852     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3853     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3854
3855     state = 0xdeadbee;
3856     action = 0xdeadbee;
3857     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3858     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3859     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3860     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3861
3862     state = 0xdeadbee;
3863     action = 0xdeadbee;
3864     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3865     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3866     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3867     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3868
3869     state = 0xdeadbee;
3870     action = 0xdeadbee;
3871     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3872     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3873     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3874     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3875
3876     state = 0xdeadbee;
3877     action = 0xdeadbee;
3878     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3879     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3880     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3881     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3882
3883     state = 0xdeadbee;
3884     action = 0xdeadbee;
3885     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3886     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3887     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3888     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3889
3890     state = 0xdeadbee;
3891     action = 0xdeadbee;
3892     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3893     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3894     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3895     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3896
3897     state = 0xdeadbee;
3898     action = 0xdeadbee;
3899     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3900     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3901     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3902     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3903
3904     state = 0xdeadbee;
3905     action = 0xdeadbee;
3906     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3907     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3908     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3909     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3910
3911     state = 0xdeadbee;
3912     action = 0xdeadbee;
3913     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3914     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3915     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3916     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3917
3918     state = 0xdeadbee;
3919     action = 0xdeadbee;
3920     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3921     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3922     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3923     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3924
3925     state = 0xdeadbee;
3926     action = 0xdeadbee;
3927     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3928     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3929     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3930     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3931
3932     state = 0xdeadbee;
3933     action = 0xdeadbee;
3934     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3935     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3936     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3937     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3938
3939     state = 0xdeadbee;
3940     action = 0xdeadbee;
3941     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3942     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3943     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3944     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3945
3946     state = 0xdeadbee;
3947     action = 0xdeadbee;
3948     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3949     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3950     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3951     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3952
3953     state = 0xdeadbee;
3954     action = 0xdeadbee;
3955     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3956     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3957     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3958     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3959
3960     state = 0xdeadbee;
3961     action = 0xdeadbee;
3962     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3963     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3964     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3965     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3966
3967     r = MsiDoAction( hpkg, "CostInitialize");
3968     ok( r == ERROR_SUCCESS, "cost init failed\n");
3969
3970     state = 0xdeadbee;
3971     action = 0xdeadbee;
3972     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3973     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3974     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3975     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3976
3977     state = 0xdeadbee;
3978     action = 0xdeadbee;
3979     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3980     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3981     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3982     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3983
3984     state = 0xdeadbee;
3985     action = 0xdeadbee;
3986     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3987     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3988     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3989     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3990
3991     state = 0xdeadbee;
3992     action = 0xdeadbee;
3993     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3994     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3995     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3996     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3997
3998     state = 0xdeadbee;
3999     action = 0xdeadbee;
4000     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4001     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4002     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4003     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4004
4005     state = 0xdeadbee;
4006     action = 0xdeadbee;
4007     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4008     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4009     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4010     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4011
4012     state = 0xdeadbee;
4013     action = 0xdeadbee;
4014     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4015     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4016     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4017     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4018
4019     state = 0xdeadbee;
4020     action = 0xdeadbee;
4021     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4022     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4023     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4024     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4025
4026     state = 0xdeadbee;
4027     action = 0xdeadbee;
4028     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4029     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4030     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4031     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4032
4033     state = 0xdeadbee;
4034     action = 0xdeadbee;
4035     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4036     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4037     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4038     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4039
4040     state = 0xdeadbee;
4041     action = 0xdeadbee;
4042     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4043     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4044     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4045     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4046
4047     state = 0xdeadbee;
4048     action = 0xdeadbee;
4049     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4050     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4051     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4052     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4053
4054     state = 0xdeadbee;
4055     action = 0xdeadbee;
4056     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4057     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4058     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4059     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4060
4061     state = 0xdeadbee;
4062     action = 0xdeadbee;
4063     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4064     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4065     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4066     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4067
4068     state = 0xdeadbee;
4069     action = 0xdeadbee;
4070     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4071     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4072     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4073     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4074
4075     state = 0xdeadbee;
4076     action = 0xdeadbee;
4077     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4079     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4080     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4081
4082     state = 0xdeadbee;
4083     action = 0xdeadbee;
4084     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4086     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4087     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4088
4089     state = 0xdeadbee;
4090     action = 0xdeadbee;
4091     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4093     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4094     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4095
4096     state = 0xdeadbee;
4097     action = 0xdeadbee;
4098     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4100     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4101     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4102
4103     state = 0xdeadbee;
4104     action = 0xdeadbee;
4105     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4107     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4108     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4109
4110     state = 0xdeadbee;
4111     action = 0xdeadbee;
4112     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4114     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4115     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4116
4117     state = 0xdeadbee;
4118     action = 0xdeadbee;
4119     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4121     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4122     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4123
4124     state = 0xdeadbee;
4125     action = 0xdeadbee;
4126     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4128     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4129     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4130
4131     state = 0xdeadbee;
4132     action = 0xdeadbee;
4133     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4135     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4136     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4137
4138     state = 0xdeadbee;
4139     action = 0xdeadbee;
4140     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4142     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4143     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4144
4145     state = 0xdeadbee;
4146     action = 0xdeadbee;
4147     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4149     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4150     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4151
4152     state = 0xdeadbee;
4153     action = 0xdeadbee;
4154     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4156     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4157     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4158
4159     state = 0xdeadbee;
4160     action = 0xdeadbee;
4161     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4163     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4164     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4165
4166     state = 0xdeadbee;
4167     action = 0xdeadbee;
4168     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4170     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4171     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4172
4173     state = 0xdeadbee;
4174     action = 0xdeadbee;
4175     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4177     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4178     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4179
4180     state = 0xdeadbee;
4181     action = 0xdeadbee;
4182     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4184     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4185     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4186
4187     r = MsiDoAction( hpkg, "FileCost");
4188     ok( r == ERROR_SUCCESS, "file cost failed\n");
4189
4190     state = 0xdeadbee;
4191     action = 0xdeadbee;
4192     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4193     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4194     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4195     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4196
4197     state = 0xdeadbee;
4198     action = 0xdeadbee;
4199     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4201     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4202     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4203
4204     state = 0xdeadbee;
4205     action = 0xdeadbee;
4206     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4208     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4209     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4210
4211     state = 0xdeadbee;
4212     action = 0xdeadbee;
4213     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4215     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4216     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4217
4218     state = 0xdeadbee;
4219     action = 0xdeadbee;
4220     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4222     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4223     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4224
4225     state = 0xdeadbee;
4226     action = 0xdeadbee;
4227     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4228     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4229     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4230     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4231
4232     state = 0xdeadbee;
4233     action = 0xdeadbee;
4234     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4235     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4236     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4237     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4238
4239     state = 0xdeadbee;
4240     action = 0xdeadbee;
4241     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4243     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4244     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4245
4246     state = 0xdeadbee;
4247     action = 0xdeadbee;
4248     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4249     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4250     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4251     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4252
4253     state = 0xdeadbee;
4254     action = 0xdeadbee;
4255     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4256     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4257     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4258     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4259
4260     state = 0xdeadbee;
4261     action = 0xdeadbee;
4262     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4263     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4264     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4265     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4266
4267     state = 0xdeadbee;
4268     action = 0xdeadbee;
4269     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4270     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4271     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4272     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4273
4274     state = 0xdeadbee;
4275     action = 0xdeadbee;
4276     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4277     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4278     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4279     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4280
4281     state = 0xdeadbee;
4282     action = 0xdeadbee;
4283     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4284     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4285     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4286     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4287
4288     state = 0xdeadbee;
4289     action = 0xdeadbee;
4290     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4291     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4292     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4293     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4294
4295     state = 0xdeadbee;
4296     action = 0xdeadbee;
4297     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4298     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4299     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4300     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4301
4302     state = 0xdeadbee;
4303     action = 0xdeadbee;
4304     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4305     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4306     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4307     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4308
4309     state = 0xdeadbee;
4310     action = 0xdeadbee;
4311     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4312     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4313     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4314     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4315
4316     state = 0xdeadbee;
4317     action = 0xdeadbee;
4318     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4319     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4320     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4321     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4322
4323     state = 0xdeadbee;
4324     action = 0xdeadbee;
4325     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4326     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4327     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4328     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4329
4330     state = 0xdeadbee;
4331     action = 0xdeadbee;
4332     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4333     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4334     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4335     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4336
4337     state = 0xdeadbee;
4338     action = 0xdeadbee;
4339     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4340     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4341     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4342     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4343
4344     state = 0xdeadbee;
4345     action = 0xdeadbee;
4346     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4347     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4348     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4349     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4350
4351     state = 0xdeadbee;
4352     action = 0xdeadbee;
4353     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4354     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4355     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4356     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4357
4358     state = 0xdeadbee;
4359     action = 0xdeadbee;
4360     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4361     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4362     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4363     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4364
4365     state = 0xdeadbee;
4366     action = 0xdeadbee;
4367     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4368     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4369     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4370     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4371
4372     state = 0xdeadbee;
4373     action = 0xdeadbee;
4374     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4375     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4376     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4377     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4378
4379     state = 0xdeadbee;
4380     action = 0xdeadbee;
4381     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4382     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4383     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4384     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4385
4386     state = 0xdeadbee;
4387     action = 0xdeadbee;
4388     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4389     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4390     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4391     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4392
4393     state = 0xdeadbee;
4394     action = 0xdeadbee;
4395     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4396     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4397     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4398     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4399
4400     r = MsiDoAction( hpkg, "CostFinalize");
4401     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4402
4403     state = 0xdeadbee;
4404     action = 0xdeadbee;
4405     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4406     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4407     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4408     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4409
4410     state = 0xdeadbee;
4411     action = 0xdeadbee;
4412     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4413     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4414     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4415     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4416
4417     state = 0xdeadbee;
4418     action = 0xdeadbee;
4419     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4420     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4421     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4422     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4423
4424     state = 0xdeadbee;
4425     action = 0xdeadbee;
4426     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4427     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4428     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4429     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4430
4431     state = 0xdeadbee;
4432     action = 0xdeadbee;
4433     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4434     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4435     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4436     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4437
4438     state = 0xdeadbee;
4439     action = 0xdeadbee;
4440     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4441     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4442     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4443     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4444
4445     state = 0xdeadbee;
4446     action = 0xdeadbee;
4447     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4448     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4449     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4450     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4451
4452     state = 0xdeadbee;
4453     action = 0xdeadbee;
4454     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4455     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4456     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4457     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4458
4459     state = 0xdeadbee;
4460     action = 0xdeadbee;
4461     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4462     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4463     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4464     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4465
4466     state = 0xdeadbee;
4467     action = 0xdeadbee;
4468     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4469     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4470     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4471     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4472
4473     state = 0xdeadbee;
4474     action = 0xdeadbee;
4475     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4476     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4477     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4478     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4479
4480     state = 0xdeadbee;
4481     action = 0xdeadbee;
4482     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4483     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4484     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4485     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4486
4487     state = 0xdeadbee;
4488     action = 0xdeadbee;
4489     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4490     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4491     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4492     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4493
4494     state = 0xdeadbee;
4495     action = 0xdeadbee;
4496     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4497     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4498     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4499     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4500
4501     state = 0xdeadbee;
4502     action = 0xdeadbee;
4503     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4504     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4505     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4506     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4507
4508     state = 0xdeadbee;
4509     action = 0xdeadbee;
4510     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4511     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4512     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4513     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4514
4515     state = 0xdeadbee;
4516     action = 0xdeadbee;
4517     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4518     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4519     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4520     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4521
4522     state = 0xdeadbee;
4523     action = 0xdeadbee;
4524     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4525     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4526     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4527     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4528
4529     state = 0xdeadbee;
4530     action = 0xdeadbee;
4531     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4532     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4533     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4534     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4535
4536     state = 0xdeadbee;
4537     action = 0xdeadbee;
4538     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4539     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4540     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4541     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4542
4543     state = 0xdeadbee;
4544     action = 0xdeadbee;
4545     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4546     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4547     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4548     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4549
4550     state = 0xdeadbee;
4551     action = 0xdeadbee;
4552     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4553     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4554     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4555     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4556
4557     state = 0xdeadbee;
4558     action = 0xdeadbee;
4559     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4560     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4561     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4562     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4563
4564     state = 0xdeadbee;
4565     action = 0xdeadbee;
4566     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4567     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4568     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4569     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4570
4571     state = 0xdeadbee;
4572     action = 0xdeadbee;
4573     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4574     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4575     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4576     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4577
4578     state = 0xdeadbee;
4579     action = 0xdeadbee;
4580     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4581     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4582     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4583     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4584
4585     state = 0xdeadbee;
4586     action = 0xdeadbee;
4587     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4588     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4589     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4590     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4591
4592     state = 0xdeadbee;
4593     action = 0xdeadbee;
4594     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4595     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4596     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4597     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4598
4599     state = 0xdeadbee;
4600     action = 0xdeadbee;
4601     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4602     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4603     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4604     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4605
4606     state = 0xdeadbee;
4607     action = 0xdeadbee;
4608     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4609     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4610     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4611     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4612
4613     state = 0xdeadbee;
4614     action = 0xdeadbee;
4615     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4616     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4617     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4618     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4619
4620     MsiCloseHandle(hpkg);
4621
4622     /* uninstall the product */
4623     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4624     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4625
4626     /* all features installed locally */
4627     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4628     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4629
4630     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4631     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4632
4633     /* these properties must not be in the saved msi file */
4634     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4635     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4636
4637     r = package_from_db( hdb, &hpkg );
4638     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
4639
4640     state = 0xdeadbee;
4641     action = 0xdeadbee;
4642     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4643     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4644     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4645     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4646
4647     state = 0xdeadbee;
4648     action = 0xdeadbee;
4649     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4650     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4651     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4652     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4653
4654     state = 0xdeadbee;
4655     action = 0xdeadbee;
4656     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4657     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4658     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4659     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4660
4661     state = 0xdeadbee;
4662     action = 0xdeadbee;
4663     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4664     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4665     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4666     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4667
4668     state = 0xdeadbee;
4669     action = 0xdeadbee;
4670     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4671     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4672     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4673     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4674
4675     state = 0xdeadbee;
4676     action = 0xdeadbee;
4677     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4678     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4679     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4680     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4681
4682     state = 0xdeadbee;
4683     action = 0xdeadbee;
4684     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4685     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4686     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4687     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4688
4689     state = 0xdeadbee;
4690     action = 0xdeadbee;
4691     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4692     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4693     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4694     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4695
4696     state = 0xdeadbee;
4697     action = 0xdeadbee;
4698     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4699     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4700     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4701     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4702
4703     state = 0xdeadbee;
4704     action = 0xdeadbee;
4705     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4706     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4707     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4708     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4709
4710     state = 0xdeadbee;
4711     action = 0xdeadbee;
4712     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4713     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4714     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4715     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4716
4717     state = 0xdeadbee;
4718     action = 0xdeadbee;
4719     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4720     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4721     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4722     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4723
4724     state = 0xdeadbee;
4725     action = 0xdeadbee;
4726     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4727     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4728     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4729     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4730
4731     state = 0xdeadbee;
4732     action = 0xdeadbee;
4733     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4734     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4735     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4736     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4737
4738     state = 0xdeadbee;
4739     action = 0xdeadbee;
4740     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4741     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4742     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4743     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4744
4745     state = 0xdeadbee;
4746     action = 0xdeadbee;
4747     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4748     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4749     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4750     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4751
4752     state = 0xdeadbee;
4753     action = 0xdeadbee;
4754     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4755     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4756     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4757     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4758
4759     state = 0xdeadbee;
4760     action = 0xdeadbee;
4761     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4762     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4763     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4764     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4765
4766     state = 0xdeadbee;
4767     action = 0xdeadbee;
4768     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4769     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4770     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4771     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4772
4773     state = 0xdeadbee;
4774     action = 0xdeadbee;
4775     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4776     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4777     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4778     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4779
4780     state = 0xdeadbee;
4781     action = 0xdeadbee;
4782     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4783     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4784     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4785     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4786
4787     state = 0xdeadbee;
4788     action = 0xdeadbee;
4789     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4790     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4791     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4792     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4793
4794     state = 0xdeadbee;
4795     action = 0xdeadbee;
4796     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4797     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4798     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4799     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4800
4801     state = 0xdeadbee;
4802     action = 0xdeadbee;
4803     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4804     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4805     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4806     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4807
4808     state = 0xdeadbee;
4809     action = 0xdeadbee;
4810     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4811     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4812     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4813     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4814
4815     state = 0xdeadbee;
4816     action = 0xdeadbee;
4817     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4818     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4819     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4820     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4821
4822     state = 0xdeadbee;
4823     action = 0xdeadbee;
4824     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4825     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4826     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4827     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4828
4829     state = 0xdeadbee;
4830     action = 0xdeadbee;
4831     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4832     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4833     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4834     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4835
4836     state = 0xdeadbee;
4837     action = 0xdeadbee;
4838     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4839     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4840     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4841     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4842
4843     state = 0xdeadbee;
4844     action = 0xdeadbee;
4845     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4846     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4847     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4848     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4849
4850     state = 0xdeadbee;
4851     action = 0xdeadbee;
4852     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4853     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4854     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4855     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4856
4857     r = MsiDoAction( hpkg, "CostInitialize");
4858     ok( r == ERROR_SUCCESS, "cost init failed\n");
4859
4860     state = 0xdeadbee;
4861     action = 0xdeadbee;
4862     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4863     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4864     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4865     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4866
4867     state = 0xdeadbee;
4868     action = 0xdeadbee;
4869     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4870     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4871     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4872     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4873
4874     state = 0xdeadbee;
4875     action = 0xdeadbee;
4876     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4877     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4878     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4879     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4880
4881     state = 0xdeadbee;
4882     action = 0xdeadbee;
4883     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4884     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4885     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4886     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4887
4888     state = 0xdeadbee;
4889     action = 0xdeadbee;
4890     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4891     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4892     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4893     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4894
4895     state = 0xdeadbee;
4896     action = 0xdeadbee;
4897     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4898     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4899     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4900     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4901
4902     state = 0xdeadbee;
4903     action = 0xdeadbee;
4904     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4905     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4906     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4907     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4908
4909     state = 0xdeadbee;
4910     action = 0xdeadbee;
4911     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4912     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4913     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4914     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4915
4916     state = 0xdeadbee;
4917     action = 0xdeadbee;
4918     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4919     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4920     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4921     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4922
4923     state = 0xdeadbee;
4924     action = 0xdeadbee;
4925     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4926     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4927     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4928     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4929
4930     state = 0xdeadbee;
4931     action = 0xdeadbee;
4932     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4933     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4934     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4935     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4936
4937     state = 0xdeadbee;
4938     action = 0xdeadbee;
4939     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4940     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4941     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4942     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4943
4944     state = 0xdeadbee;
4945     action = 0xdeadbee;
4946     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4947     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4948     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4949     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4950
4951     state = 0xdeadbee;
4952     action = 0xdeadbee;
4953     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4954     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4955     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4956     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4957
4958     state = 0xdeadbee;
4959     action = 0xdeadbee;
4960     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4961     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4962     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4963     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4964
4965     state = 0xdeadbee;
4966     action = 0xdeadbee;
4967     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4968     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4969     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4970     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4971
4972     state = 0xdeadbee;
4973     action = 0xdeadbee;
4974     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4975     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4976     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4977     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4978
4979     state = 0xdeadbee;
4980     action = 0xdeadbee;
4981     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4982     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4983     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4984     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4985
4986     state = 0xdeadbee;
4987     action = 0xdeadbee;
4988     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4989     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4990     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4991     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4992
4993     state = 0xdeadbee;
4994     action = 0xdeadbee;
4995     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4996     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4997     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4998     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4999
5000     state = 0xdeadbee;
5001     action = 0xdeadbee;
5002     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5003     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5004     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5005     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5006
5007     state = 0xdeadbee;
5008     action = 0xdeadbee;
5009     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5010     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5011     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5012     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5013
5014     state = 0xdeadbee;
5015     action = 0xdeadbee;
5016     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5017     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5018     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5019     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5020
5021     state = 0xdeadbee;
5022     action = 0xdeadbee;
5023     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5024     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5025     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5026     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5027
5028     state = 0xdeadbee;
5029     action = 0xdeadbee;
5030     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5031     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5032     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5033     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5034
5035     state = 0xdeadbee;
5036     action = 0xdeadbee;
5037     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5038     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5039     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5040     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5041
5042     state = 0xdeadbee;
5043     action = 0xdeadbee;
5044     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5045     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5046     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5047     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5048
5049     state = 0xdeadbee;
5050     action = 0xdeadbee;
5051     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5052     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5053     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5054     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5055
5056     state = 0xdeadbee;
5057     action = 0xdeadbee;
5058     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5059     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5060     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5061     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5062
5063     state = 0xdeadbee;
5064     action = 0xdeadbee;
5065     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5066     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5067     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5068     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5069
5070     state = 0xdeadbee;
5071     action = 0xdeadbee;
5072     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5073     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5074     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5075     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5076
5077     r = MsiDoAction( hpkg, "FileCost");
5078     ok( r == ERROR_SUCCESS, "file cost failed\n");
5079
5080     state = 0xdeadbee;
5081     action = 0xdeadbee;
5082     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5083     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5084     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5085     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5086
5087     state = 0xdeadbee;
5088     action = 0xdeadbee;
5089     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5090     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5091     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5092     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5093
5094     state = 0xdeadbee;
5095     action = 0xdeadbee;
5096     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5097     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5098     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5099     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5100
5101     state = 0xdeadbee;
5102     action = 0xdeadbee;
5103     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5104     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5105     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5106     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5107
5108     state = 0xdeadbee;
5109     action = 0xdeadbee;
5110     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5111     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5112     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5113     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5114
5115     state = 0xdeadbee;
5116     action = 0xdeadbee;
5117     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5118     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5119     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5120     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5121
5122     state = 0xdeadbee;
5123     action = 0xdeadbee;
5124     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5125     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5126     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5127     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5128
5129     state = 0xdeadbee;
5130     action = 0xdeadbee;
5131     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5132     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5133     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5134     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5135
5136     state = 0xdeadbee;
5137     action = 0xdeadbee;
5138     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5139     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5140     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5141     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5142
5143     state = 0xdeadbee;
5144     action = 0xdeadbee;
5145     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5146     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5147     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5148     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5149
5150     state = 0xdeadbee;
5151     action = 0xdeadbee;
5152     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5153     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5154     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5155     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5156
5157     state = 0xdeadbee;
5158     action = 0xdeadbee;
5159     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5160     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5161     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5162     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5163
5164     state = 0xdeadbee;
5165     action = 0xdeadbee;
5166     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5167     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5168     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5169     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5170
5171     state = 0xdeadbee;
5172     action = 0xdeadbee;
5173     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5174     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5175     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5176     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5177
5178     state = 0xdeadbee;
5179     action = 0xdeadbee;
5180     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5181     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5182     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5183     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5184
5185     state = 0xdeadbee;
5186     action = 0xdeadbee;
5187     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5188     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5189     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5190     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5191
5192     state = 0xdeadbee;
5193     action = 0xdeadbee;
5194     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5195     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5196     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5197     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5198
5199     state = 0xdeadbee;
5200     action = 0xdeadbee;
5201     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5202     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5203     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5204     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5205
5206     state = 0xdeadbee;
5207     action = 0xdeadbee;
5208     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5209     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5210     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5211     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5212
5213     state = 0xdeadbee;
5214     action = 0xdeadbee;
5215     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5216     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5217     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5218     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5219
5220     state = 0xdeadbee;
5221     action = 0xdeadbee;
5222     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5223     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5224     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5225     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5226
5227     state = 0xdeadbee;
5228     action = 0xdeadbee;
5229     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5230     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5231     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5232     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5233
5234     state = 0xdeadbee;
5235     action = 0xdeadbee;
5236     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5237     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5238     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5239     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5240
5241     state = 0xdeadbee;
5242     action = 0xdeadbee;
5243     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5244     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5245     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5246     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5247
5248     state = 0xdeadbee;
5249     action = 0xdeadbee;
5250     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5251     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5252     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5253     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5254
5255     state = 0xdeadbee;
5256     action = 0xdeadbee;
5257     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5258     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5259     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5260     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5261
5262     state = 0xdeadbee;
5263     action = 0xdeadbee;
5264     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5265     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5266     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5267     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5268
5269     state = 0xdeadbee;
5270     action = 0xdeadbee;
5271     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5272     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5273     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5274     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5275
5276     state = 0xdeadbee;
5277     action = 0xdeadbee;
5278     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5279     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5280     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5281     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5282
5283     state = 0xdeadbee;
5284     action = 0xdeadbee;
5285     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5286     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5287     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5288     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5289
5290     state = 0xdeadbee;
5291     action = 0xdeadbee;
5292     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5293     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5294     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5295     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5296
5297     r = MsiDoAction( hpkg, "CostFinalize");
5298     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5299
5300     state = 0xdeadbee;
5301     action = 0xdeadbee;
5302     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5303     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5304     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5305     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5306
5307     state = 0xdeadbee;
5308     action = 0xdeadbee;
5309     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5310     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5311     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5312     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5313
5314     state = 0xdeadbee;
5315     action = 0xdeadbee;
5316     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5317     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5318     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5319     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5320
5321     state = 0xdeadbee;
5322     action = 0xdeadbee;
5323     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5324     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5325     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5326     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5327
5328     state = 0xdeadbee;
5329     action = 0xdeadbee;
5330     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5331     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5332     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5333     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5334
5335     state = 0xdeadbee;
5336     action = 0xdeadbee;
5337     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5338     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5339     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5340     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5341
5342     state = 0xdeadbee;
5343     action = 0xdeadbee;
5344     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5345     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5346     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5347     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5348
5349     state = 0xdeadbee;
5350     action = 0xdeadbee;
5351     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5352     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5353     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5354     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5355
5356     state = 0xdeadbee;
5357     action = 0xdeadbee;
5358     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5359     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5360     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5361     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5362
5363     state = 0xdeadbee;
5364     action = 0xdeadbee;
5365     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5366     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5367     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5368     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5369
5370     state = 0xdeadbee;
5371     action = 0xdeadbee;
5372     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5373     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5374     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5375     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5376
5377     state = 0xdeadbee;
5378     action = 0xdeadbee;
5379     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5380     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5381     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5382     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5383
5384     state = 0xdeadbee;
5385     action = 0xdeadbee;
5386     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5387     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5388     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5389     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5390
5391     state = 0xdeadbee;
5392     action = 0xdeadbee;
5393     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5394     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5395     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5396     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5397
5398     state = 0xdeadbee;
5399     action = 0xdeadbee;
5400     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5401     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5402     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5403     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5404
5405     state = 0xdeadbee;
5406     action = 0xdeadbee;
5407     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5408     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5409     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5410     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5411
5412     state = 0xdeadbee;
5413     action = 0xdeadbee;
5414     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5415     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5416     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5417     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5418
5419     state = 0xdeadbee;
5420     action = 0xdeadbee;
5421     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5422     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5423     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5424     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5425
5426     state = 0xdeadbee;
5427     action = 0xdeadbee;
5428     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5429     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5430     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5431     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5432
5433     state = 0xdeadbee;
5434     action = 0xdeadbee;
5435     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5436     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5437     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5438     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5439
5440     state = 0xdeadbee;
5441     action = 0xdeadbee;
5442     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5443     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5444     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5445     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5446
5447     state = 0xdeadbee;
5448     action = 0xdeadbee;
5449     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5450     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5451     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5452     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5453
5454     state = 0xdeadbee;
5455     action = 0xdeadbee;
5456     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5457     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5458     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5459     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5460
5461     state = 0xdeadbee;
5462     action = 0xdeadbee;
5463     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5464     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5465     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5466     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5467
5468     state = 0xdeadbee;
5469     action = 0xdeadbee;
5470     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5471     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5472     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5473     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5474
5475     state = 0xdeadbee;
5476     action = 0xdeadbee;
5477     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5478     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5479     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5480     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5481
5482     state = 0xdeadbee;
5483     action = 0xdeadbee;
5484     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5485     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5486     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5487     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5488
5489     state = 0xdeadbee;
5490     action = 0xdeadbee;
5491     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5492     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5493     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5494     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5495
5496     state = 0xdeadbee;
5497     action = 0xdeadbee;
5498     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5499     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5500     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5501     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5502
5503     state = 0xdeadbee;
5504     action = 0xdeadbee;
5505     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5506     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5507     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5508     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5509
5510     state = 0xdeadbee;
5511     action = 0xdeadbee;
5512     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5513     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5514     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5515     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5516
5517     MsiCloseHandle(hpkg);
5518
5519     /* uninstall the product */
5520     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5522
5523     /* all features installed from source */
5524     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5526
5527     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5528     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5529
5530     /* this property must not be in the saved msi file */
5531     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5532     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5533
5534     r = package_from_db( hdb, &hpkg );
5535     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5536
5537     state = 0xdeadbee;
5538     action = 0xdeadbee;
5539     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5540     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5541     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5542     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5543
5544     state = 0xdeadbee;
5545     action = 0xdeadbee;
5546     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5547     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5548     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5549     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5550
5551     state = 0xdeadbee;
5552     action = 0xdeadbee;
5553     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5554     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5555     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5556     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5557
5558     state = 0xdeadbee;
5559     action = 0xdeadbee;
5560     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5561     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5562     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5563     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5564
5565     state = 0xdeadbee;
5566     action = 0xdeadbee;
5567     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5568     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5569     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5570     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5571
5572     state = 0xdeadbee;
5573     action = 0xdeadbee;
5574     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5575     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5576     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5577     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5578
5579     state = 0xdeadbee;
5580     action = 0xdeadbee;
5581     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5582     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5583     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5584     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5585
5586     state = 0xdeadbee;
5587     action = 0xdeadbee;
5588     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5589     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5590     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5591     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5592
5593     state = 0xdeadbee;
5594     action = 0xdeadbee;
5595     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5596     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5597     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5598     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5599
5600     state = 0xdeadbee;
5601     action = 0xdeadbee;
5602     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5603     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5604     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5605     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5606
5607     state = 0xdeadbee;
5608     action = 0xdeadbee;
5609     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5610     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5611     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5612     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5613
5614     state = 0xdeadbee;
5615     action = 0xdeadbee;
5616     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5617     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5618     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5619     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5620
5621     state = 0xdeadbee;
5622     action = 0xdeadbee;
5623     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5624     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5625     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5626     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5627
5628     state = 0xdeadbee;
5629     action = 0xdeadbee;
5630     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5631     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5632     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5633     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5634
5635     state = 0xdeadbee;
5636     action = 0xdeadbee;
5637     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5638     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5639     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5640     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5641
5642     state = 0xdeadbee;
5643     action = 0xdeadbee;
5644     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5645     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5646     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5647     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5648
5649     state = 0xdeadbee;
5650     action = 0xdeadbee;
5651     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5652     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5653     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5654     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5655
5656     state = 0xdeadbee;
5657     action = 0xdeadbee;
5658     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5659     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5660     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5661     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5662
5663     state = 0xdeadbee;
5664     action = 0xdeadbee;
5665     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5666     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5667     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5668     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5669
5670     state = 0xdeadbee;
5671     action = 0xdeadbee;
5672     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5673     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5674     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5675     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5676
5677     state = 0xdeadbee;
5678     action = 0xdeadbee;
5679     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5680     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5681     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5682     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5683
5684     state = 0xdeadbee;
5685     action = 0xdeadbee;
5686     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5687     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5688     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5689     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5690
5691     state = 0xdeadbee;
5692     action = 0xdeadbee;
5693     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5694     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5695     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5696     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5697
5698     state = 0xdeadbee;
5699     action = 0xdeadbee;
5700     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5701     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5702     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5703     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5704
5705     state = 0xdeadbee;
5706     action = 0xdeadbee;
5707     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5708     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5709     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5710     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5711
5712     state = 0xdeadbee;
5713     action = 0xdeadbee;
5714     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5715     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5716     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5717     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5718
5719     state = 0xdeadbee;
5720     action = 0xdeadbee;
5721     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5722     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5723     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5724     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5725
5726     state = 0xdeadbee;
5727     action = 0xdeadbee;
5728     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5729     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5730     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5731     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5732
5733     state = 0xdeadbee;
5734     action = 0xdeadbee;
5735     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5736     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5737     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5738     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5739
5740     state = 0xdeadbee;
5741     action = 0xdeadbee;
5742     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5743     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5744     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5745     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5746
5747     state = 0xdeadbee;
5748     action = 0xdeadbee;
5749     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5750     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5751     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5752     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5753
5754     r = MsiDoAction( hpkg, "CostInitialize");
5755     ok( r == ERROR_SUCCESS, "cost init failed\n");
5756
5757     state = 0xdeadbee;
5758     action = 0xdeadbee;
5759     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5760     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5761     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5762     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5763
5764     state = 0xdeadbee;
5765     action = 0xdeadbee;
5766     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5767     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5768     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5769     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5770
5771     state = 0xdeadbee;
5772     action = 0xdeadbee;
5773     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5774     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5775     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5776     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5777
5778     state = 0xdeadbee;
5779     action = 0xdeadbee;
5780     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5781     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5782     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5783     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5784
5785     state = 0xdeadbee;
5786     action = 0xdeadbee;
5787     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5788     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5789     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5790     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5791
5792     state = 0xdeadbee;
5793     action = 0xdeadbee;
5794     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5795     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5796     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5797     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5798
5799     state = 0xdeadbee;
5800     action = 0xdeadbee;
5801     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5802     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5803     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5804     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5805
5806     state = 0xdeadbee;
5807     action = 0xdeadbee;
5808     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5809     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5810     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5811     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5812
5813     state = 0xdeadbee;
5814     action = 0xdeadbee;
5815     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5816     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5817     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5818     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5819
5820     state = 0xdeadbee;
5821     action = 0xdeadbee;
5822     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5823     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5824     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5825     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5826
5827     state = 0xdeadbee;
5828     action = 0xdeadbee;
5829     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5830     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5831     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5832     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5833
5834     state = 0xdeadbee;
5835     action = 0xdeadbee;
5836     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5837     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5838     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5839     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5840
5841     state = 0xdeadbee;
5842     action = 0xdeadbee;
5843     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5844     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5845     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5846     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5847
5848     state = 0xdeadbee;
5849     action = 0xdeadbee;
5850     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5851     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5852     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5853     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5854
5855     state = 0xdeadbee;
5856     action = 0xdeadbee;
5857     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5858     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5859     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5860     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5861
5862     state = 0xdeadbee;
5863     action = 0xdeadbee;
5864     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5865     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5866     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5867     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5868
5869     state = 0xdeadbee;
5870     action = 0xdeadbee;
5871     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5872     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5873     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5874     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5875
5876     state = 0xdeadbee;
5877     action = 0xdeadbee;
5878     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5879     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5880     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5881     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5882
5883     state = 0xdeadbee;
5884     action = 0xdeadbee;
5885     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5886     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5887     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5888     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5889
5890     state = 0xdeadbee;
5891     action = 0xdeadbee;
5892     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5893     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5894     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5895     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5896
5897     state = 0xdeadbee;
5898     action = 0xdeadbee;
5899     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5900     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5901     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5902     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5903
5904     state = 0xdeadbee;
5905     action = 0xdeadbee;
5906     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5907     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5908     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5909     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5910
5911     state = 0xdeadbee;
5912     action = 0xdeadbee;
5913     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5914     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5915     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5916     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5917
5918     state = 0xdeadbee;
5919     action = 0xdeadbee;
5920     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5921     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5922     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5923     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5924
5925     state = 0xdeadbee;
5926     action = 0xdeadbee;
5927     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5928     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5929     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5930     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5931
5932     state = 0xdeadbee;
5933     action = 0xdeadbee;
5934     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5935     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5936     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5937     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5938
5939     state = 0xdeadbee;
5940     action = 0xdeadbee;
5941     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5942     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5943     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5944     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5945
5946     state = 0xdeadbee;
5947     action = 0xdeadbee;
5948     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5949     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5950     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5951     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5952
5953     state = 0xdeadbee;
5954     action = 0xdeadbee;
5955     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5956     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5957     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5958     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5959
5960     state = 0xdeadbee;
5961     action = 0xdeadbee;
5962     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5963     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5964     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5965     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5966
5967     state = 0xdeadbee;
5968     action = 0xdeadbee;
5969     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5970     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5971     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5972     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5973
5974     r = MsiDoAction( hpkg, "FileCost");
5975     ok( r == ERROR_SUCCESS, "file cost failed\n");
5976
5977     state = 0xdeadbee;
5978     action = 0xdeadbee;
5979     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5980     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5981     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5982     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5983
5984     state = 0xdeadbee;
5985     action = 0xdeadbee;
5986     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5987     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5988     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5989     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5990
5991     state = 0xdeadbee;
5992     action = 0xdeadbee;
5993     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5994     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5995     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5996     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5997
5998     state = 0xdeadbee;
5999     action = 0xdeadbee;
6000     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6001     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6002     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6003     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6004
6005     state = 0xdeadbee;
6006     action = 0xdeadbee;
6007     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6008     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6009     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6010     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6011
6012     state = 0xdeadbee;
6013     action = 0xdeadbee;
6014     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6015     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6016     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6017     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6018
6019     state = 0xdeadbee;
6020     action = 0xdeadbee;
6021     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6022     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6023     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6024     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6025
6026     state = 0xdeadbee;
6027     action = 0xdeadbee;
6028     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6029     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6030     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6031     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6032
6033     state = 0xdeadbee;
6034     action = 0xdeadbee;
6035     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6036     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6037     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6038     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6039
6040     state = 0xdeadbee;
6041     action = 0xdeadbee;
6042     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6043     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6044     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6045     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6046
6047     state = 0xdeadbee;
6048     action = 0xdeadbee;
6049     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6050     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6051     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6052     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6053
6054     state = 0xdeadbee;
6055     action = 0xdeadbee;
6056     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6057     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6058     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6059     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6060
6061     state = 0xdeadbee;
6062     action = 0xdeadbee;
6063     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6064     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6065     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6066     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6067
6068     state = 0xdeadbee;
6069     action = 0xdeadbee;
6070     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6071     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6072     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6073     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6074
6075     state = 0xdeadbee;
6076     action = 0xdeadbee;
6077     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6079     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6080     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6081
6082     state = 0xdeadbee;
6083     action = 0xdeadbee;
6084     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6086     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6087     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6088
6089     state = 0xdeadbee;
6090     action = 0xdeadbee;
6091     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6093     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6094     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6095
6096     state = 0xdeadbee;
6097     action = 0xdeadbee;
6098     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6100     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6101     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6102
6103     state = 0xdeadbee;
6104     action = 0xdeadbee;
6105     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6107     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6108     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6109
6110     state = 0xdeadbee;
6111     action = 0xdeadbee;
6112     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6114     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6115     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6116
6117     state = 0xdeadbee;
6118     action = 0xdeadbee;
6119     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6121     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6122     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6123
6124     state = 0xdeadbee;
6125     action = 0xdeadbee;
6126     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6128     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6129     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6130
6131     state = 0xdeadbee;
6132     action = 0xdeadbee;
6133     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6135     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6136     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6137
6138     state = 0xdeadbee;
6139     action = 0xdeadbee;
6140     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6142     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6143     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6144
6145     state = 0xdeadbee;
6146     action = 0xdeadbee;
6147     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6149     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6150     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6151
6152     state = 0xdeadbee;
6153     action = 0xdeadbee;
6154     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6156     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6157     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6158
6159     state = 0xdeadbee;
6160     action = 0xdeadbee;
6161     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6163     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6164     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6165
6166     state = 0xdeadbee;
6167     action = 0xdeadbee;
6168     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6170     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6171     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6172
6173     state = 0xdeadbee;
6174     action = 0xdeadbee;
6175     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6177     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6178     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6179
6180     state = 0xdeadbee;
6181     action = 0xdeadbee;
6182     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6184     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6185     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6186
6187     state = 0xdeadbee;
6188     action = 0xdeadbee;
6189     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6191     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6192     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6193
6194     r = MsiDoAction( hpkg, "CostFinalize");
6195     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6196
6197     state = 0xdeadbee;
6198     action = 0xdeadbee;
6199     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6201     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6202     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6203
6204     state = 0xdeadbee;
6205     action = 0xdeadbee;
6206     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6208     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6209     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6210
6211     state = 0xdeadbee;
6212     action = 0xdeadbee;
6213     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6215     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6216     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6217
6218     state = 0xdeadbee;
6219     action = 0xdeadbee;
6220     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6222     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6223     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6224
6225     state = 0xdeadbee;
6226     action = 0xdeadbee;
6227     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6228     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6229     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6230     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6231
6232     state = 0xdeadbee;
6233     action = 0xdeadbee;
6234     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6235     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6236     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6237     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6238
6239     state = 0xdeadbee;
6240     action = 0xdeadbee;
6241     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6243     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6244     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6245
6246     state = 0xdeadbee;
6247     action = 0xdeadbee;
6248     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6249     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6250     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6251     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6252
6253     state = 0xdeadbee;
6254     action = 0xdeadbee;
6255     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6256     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6257     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6258     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6259
6260     state = 0xdeadbee;
6261     action = 0xdeadbee;
6262     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6263     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6264     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6265     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6266
6267     state = 0xdeadbee;
6268     action = 0xdeadbee;
6269     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6270     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6271     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6272     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6273
6274     state = 0xdeadbee;
6275     action = 0xdeadbee;
6276     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6277     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6278     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6279     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6280
6281     state = 0xdeadbee;
6282     action = 0xdeadbee;
6283     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6284     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6285     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6286     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6287
6288     state = 0xdeadbee;
6289     action = 0xdeadbee;
6290     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6291     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6292     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6293     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6294
6295     state = 0xdeadbee;
6296     action = 0xdeadbee;
6297     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6298     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6299     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6300     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6301
6302     state = 0xdeadbee;
6303     action = 0xdeadbee;
6304     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6305     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6306     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6307     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6308
6309     state = 0xdeadbee;
6310     action = 0xdeadbee;
6311     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6312     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6313     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6314     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6315
6316     state = 0xdeadbee;
6317     action = 0xdeadbee;
6318     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6319     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6320     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6321     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6322
6323     state = 0xdeadbee;
6324     action = 0xdeadbee;
6325     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6326     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6327     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6328     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6329
6330     state = 0xdeadbee;
6331     action = 0xdeadbee;
6332     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6333     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6334     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6335     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6336
6337     state = 0xdeadbee;
6338     action = 0xdeadbee;
6339     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6340     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6341     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6342     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6343
6344     state = 0xdeadbee;
6345     action = 0xdeadbee;
6346     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6347     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6348     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6349     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6350
6351     state = 0xdeadbee;
6352     action = 0xdeadbee;
6353     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6354     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6355     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6356     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6357
6358     state = 0xdeadbee;
6359     action = 0xdeadbee;
6360     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6361     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6362     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6363     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6364
6365     state = 0xdeadbee;
6366     action = 0xdeadbee;
6367     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6368     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6369     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6370     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6371
6372     state = 0xdeadbee;
6373     action = 0xdeadbee;
6374     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6375     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6376     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6377     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6378
6379     state = 0xdeadbee;
6380     action = 0xdeadbee;
6381     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6382     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6383     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6384     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6385
6386     state = 0xdeadbee;
6387     action = 0xdeadbee;
6388     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6389     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6390     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6391     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6392
6393     state = 0xdeadbee;
6394     action = 0xdeadbee;
6395     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6396     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6397     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6398     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6399
6400     state = 0xdeadbee;
6401     action = 0xdeadbee;
6402     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6403     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6404     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6405     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6406
6407     state = 0xdeadbee;
6408     action = 0xdeadbee;
6409     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6410     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6411     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6412     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6413
6414     MsiCloseHandle(hpkg);
6415
6416     /* reinstall the product */
6417     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6419
6420     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6421     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6422
6423     /* this property must not be in the saved msi file */
6424     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6425     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6426
6427     r = package_from_db( hdb, &hpkg );
6428     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6429
6430     state = 0xdeadbee;
6431     action = 0xdeadbee;
6432     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6433     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6434     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6435     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6436
6437     state = 0xdeadbee;
6438     action = 0xdeadbee;
6439     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6440     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6441     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6442     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6443
6444     state = 0xdeadbee;
6445     action = 0xdeadbee;
6446     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6447     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6448     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6449     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6450
6451     state = 0xdeadbee;
6452     action = 0xdeadbee;
6453     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6454     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6455     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6456     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6457
6458     state = 0xdeadbee;
6459     action = 0xdeadbee;
6460     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6461     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6462     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6463     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6464
6465     state = 0xdeadbee;
6466     action = 0xdeadbee;
6467     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6468     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6469     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6470     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6471
6472     state = 0xdeadbee;
6473     action = 0xdeadbee;
6474     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6475     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6476     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6477     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6478
6479     state = 0xdeadbee;
6480     action = 0xdeadbee;
6481     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6482     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6483     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6484     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6485
6486     state = 0xdeadbee;
6487     action = 0xdeadbee;
6488     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6489     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6490     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6491     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6492
6493     state = 0xdeadbee;
6494     action = 0xdeadbee;
6495     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6496     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6497     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6498     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6499
6500     state = 0xdeadbee;
6501     action = 0xdeadbee;
6502     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6503     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6504     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6505     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6506
6507     state = 0xdeadbee;
6508     action = 0xdeadbee;
6509     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6510     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6511     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6512     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6513
6514     state = 0xdeadbee;
6515     action = 0xdeadbee;
6516     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6517     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6518     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6519     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6520
6521     state = 0xdeadbee;
6522     action = 0xdeadbee;
6523     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6524     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6525     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6526     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6527
6528     state = 0xdeadbee;
6529     action = 0xdeadbee;
6530     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6531     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6532     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6533     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6534
6535     state = 0xdeadbee;
6536     action = 0xdeadbee;
6537     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6538     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6539     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6540     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6541
6542     state = 0xdeadbee;
6543     action = 0xdeadbee;
6544     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6545     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6546     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6547     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6548
6549     state = 0xdeadbee;
6550     action = 0xdeadbee;
6551     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6552     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6553     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6554     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6555
6556     state = 0xdeadbee;
6557     action = 0xdeadbee;
6558     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6559     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6560     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6561     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6562
6563     state = 0xdeadbee;
6564     action = 0xdeadbee;
6565     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6566     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6567     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6568     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6569
6570     state = 0xdeadbee;
6571     action = 0xdeadbee;
6572     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6573     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6574     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6575     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6576
6577     state = 0xdeadbee;
6578     action = 0xdeadbee;
6579     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6580     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6581     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6582     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6583
6584     state = 0xdeadbee;
6585     action = 0xdeadbee;
6586     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6587     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6588     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6589     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6590
6591     state = 0xdeadbee;
6592     action = 0xdeadbee;
6593     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6594     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6595     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6596     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6597
6598     state = 0xdeadbee;
6599     action = 0xdeadbee;
6600     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6601     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6602     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6603     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6604
6605     state = 0xdeadbee;
6606     action = 0xdeadbee;
6607     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6608     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6609     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6610     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6611
6612     state = 0xdeadbee;
6613     action = 0xdeadbee;
6614     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6615     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6616     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6617     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6618
6619     state = 0xdeadbee;
6620     action = 0xdeadbee;
6621     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6622     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6623     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6624     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6625
6626     state = 0xdeadbee;
6627     action = 0xdeadbee;
6628     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6629     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6630     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6631     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6632
6633     state = 0xdeadbee;
6634     action = 0xdeadbee;
6635     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6636     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6637     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6638     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6639
6640     state = 0xdeadbee;
6641     action = 0xdeadbee;
6642     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6643     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6644     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6645     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6646
6647     r = MsiDoAction( hpkg, "CostInitialize");
6648     ok( r == ERROR_SUCCESS, "cost init failed\n");
6649
6650     state = 0xdeadbee;
6651     action = 0xdeadbee;
6652     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6653     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6654     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6655     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6656
6657     state = 0xdeadbee;
6658     action = 0xdeadbee;
6659     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6660     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6661     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6662     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6663
6664     state = 0xdeadbee;
6665     action = 0xdeadbee;
6666     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6667     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6668     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6669     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6670
6671     state = 0xdeadbee;
6672     action = 0xdeadbee;
6673     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6674     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6675     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6676     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6677
6678     state = 0xdeadbee;
6679     action = 0xdeadbee;
6680     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6681     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6682     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6683     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6684
6685     state = 0xdeadbee;
6686     action = 0xdeadbee;
6687     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6688     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6689     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6690     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6691
6692     state = 0xdeadbee;
6693     action = 0xdeadbee;
6694     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6695     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6696     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6697     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6698
6699     state = 0xdeadbee;
6700     action = 0xdeadbee;
6701     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6702     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6703     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6704     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6705
6706     state = 0xdeadbee;
6707     action = 0xdeadbee;
6708     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6709     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6710     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6711     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6712
6713     state = 0xdeadbee;
6714     action = 0xdeadbee;
6715     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6716     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6717     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6718     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6719
6720     state = 0xdeadbee;
6721     action = 0xdeadbee;
6722     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6723     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6724     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6725     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6726
6727     state = 0xdeadbee;
6728     action = 0xdeadbee;
6729     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6730     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6731     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6732     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6733
6734     state = 0xdeadbee;
6735     action = 0xdeadbee;
6736     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6737     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6738     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6739     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6740
6741     state = 0xdeadbee;
6742     action = 0xdeadbee;
6743     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6744     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6745     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6746     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6747
6748     state = 0xdeadbee;
6749     action = 0xdeadbee;
6750     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6751     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6752     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6753     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6754
6755     state = 0xdeadbee;
6756     action = 0xdeadbee;
6757     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6758     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6759     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6760     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6761
6762     state = 0xdeadbee;
6763     action = 0xdeadbee;
6764     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6765     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6766     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6767     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6768
6769     state = 0xdeadbee;
6770     action = 0xdeadbee;
6771     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6772     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6773     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6774     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6775
6776     state = 0xdeadbee;
6777     action = 0xdeadbee;
6778     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6779     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6780     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6781     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6782
6783     state = 0xdeadbee;
6784     action = 0xdeadbee;
6785     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6786     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6787     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6788     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6789
6790     state = 0xdeadbee;
6791     action = 0xdeadbee;
6792     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6793     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6794     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6795     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6796
6797     state = 0xdeadbee;
6798     action = 0xdeadbee;
6799     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6800     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6801     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6802     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6803
6804     state = 0xdeadbee;
6805     action = 0xdeadbee;
6806     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6807     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6808     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6809     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6810
6811     state = 0xdeadbee;
6812     action = 0xdeadbee;
6813     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6814     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6815     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6816     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6817
6818     state = 0xdeadbee;
6819     action = 0xdeadbee;
6820     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6821     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6822     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6823     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6824
6825     state = 0xdeadbee;
6826     action = 0xdeadbee;
6827     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6828     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6829     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6830     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6831
6832     state = 0xdeadbee;
6833     action = 0xdeadbee;
6834     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6835     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6836     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6837     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6838
6839     state = 0xdeadbee;
6840     action = 0xdeadbee;
6841     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6842     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6843     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6844     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6845
6846     state = 0xdeadbee;
6847     action = 0xdeadbee;
6848     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6849     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6850     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6851     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6852
6853     state = 0xdeadbee;
6854     action = 0xdeadbee;
6855     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6856     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6857     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6858     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6859
6860     state = 0xdeadbee;
6861     action = 0xdeadbee;
6862     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6863     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6864     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6865     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6866
6867     r = MsiDoAction( hpkg, "FileCost");
6868     ok( r == ERROR_SUCCESS, "file cost failed\n");
6869
6870     state = 0xdeadbee;
6871     action = 0xdeadbee;
6872     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6873     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6874     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6875     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6876
6877     state = 0xdeadbee;
6878     action = 0xdeadbee;
6879     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6880     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6881     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6882     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6883
6884     state = 0xdeadbee;
6885     action = 0xdeadbee;
6886     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6887     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6888     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6889     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6890
6891     state = 0xdeadbee;
6892     action = 0xdeadbee;
6893     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6894     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6895     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6896     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6897
6898     state = 0xdeadbee;
6899     action = 0xdeadbee;
6900     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6901     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6902     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6903     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6904
6905     state = 0xdeadbee;
6906     action = 0xdeadbee;
6907     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6908     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6909     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6910     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6911
6912     state = 0xdeadbee;
6913     action = 0xdeadbee;
6914     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6915     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6916     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6917     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6918
6919     state = 0xdeadbee;
6920     action = 0xdeadbee;
6921     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6922     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6923     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6924     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6925
6926     state = 0xdeadbee;
6927     action = 0xdeadbee;
6928     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6929     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6930     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6931     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6932
6933     state = 0xdeadbee;
6934     action = 0xdeadbee;
6935     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6936     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6937     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6938     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6939
6940     state = 0xdeadbee;
6941     action = 0xdeadbee;
6942     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6943     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6944     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6945     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6946
6947     state = 0xdeadbee;
6948     action = 0xdeadbee;
6949     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6950     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6951     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6952     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6953
6954     state = 0xdeadbee;
6955     action = 0xdeadbee;
6956     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6957     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6958     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6959     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6960
6961     state = 0xdeadbee;
6962     action = 0xdeadbee;
6963     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6964     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6965     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6966     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6967
6968     state = 0xdeadbee;
6969     action = 0xdeadbee;
6970     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6971     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6972     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6973     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6974
6975     state = 0xdeadbee;
6976     action = 0xdeadbee;
6977     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6978     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6979     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6980     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6981
6982     state = 0xdeadbee;
6983     action = 0xdeadbee;
6984     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6985     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6986     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6987     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6988
6989     state = 0xdeadbee;
6990     action = 0xdeadbee;
6991     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6992     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6993     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6994     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6995
6996     state = 0xdeadbee;
6997     action = 0xdeadbee;
6998     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6999     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7000     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7001     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7002
7003     state = 0xdeadbee;
7004     action = 0xdeadbee;
7005     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7006     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7007     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7008     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7009
7010     state = 0xdeadbee;
7011     action = 0xdeadbee;
7012     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7013     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7014     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7015     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7016
7017     state = 0xdeadbee;
7018     action = 0xdeadbee;
7019     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7020     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7021     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7022     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7023
7024     state = 0xdeadbee;
7025     action = 0xdeadbee;
7026     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7027     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7028     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7029     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7030
7031     state = 0xdeadbee;
7032     action = 0xdeadbee;
7033     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7034     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7035     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7036     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7037
7038     state = 0xdeadbee;
7039     action = 0xdeadbee;
7040     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7041     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7042     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7043     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7044
7045     state = 0xdeadbee;
7046     action = 0xdeadbee;
7047     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7048     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7049     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7050     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7051
7052     state = 0xdeadbee;
7053     action = 0xdeadbee;
7054     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7055     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7056     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7057     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7058
7059     state = 0xdeadbee;
7060     action = 0xdeadbee;
7061     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7062     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7063     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7064     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7065
7066     state = 0xdeadbee;
7067     action = 0xdeadbee;
7068     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7069     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7070     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7071     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7072
7073     state = 0xdeadbee;
7074     action = 0xdeadbee;
7075     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7076     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7077     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7078     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7079
7080     state = 0xdeadbee;
7081     action = 0xdeadbee;
7082     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7083     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7084     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7085     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7086
7087     r = MsiDoAction( hpkg, "CostFinalize");
7088     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
7089
7090     state = 0xdeadbee;
7091     action = 0xdeadbee;
7092     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7093     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7094     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7095     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7096
7097     state = 0xdeadbee;
7098     action = 0xdeadbee;
7099     r = MsiGetFeatureState(hpkg, "two", &state, &action);
7100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7101     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7102     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7103
7104     state = 0xdeadbee;
7105     action = 0xdeadbee;
7106     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7108     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7109     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7110
7111     state = 0xdeadbee;
7112     action = 0xdeadbee;
7113     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7115     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7116     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7117
7118     state = 0xdeadbee;
7119     action = 0xdeadbee;
7120     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7122     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7123     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7124
7125     state = 0xdeadbee;
7126     action = 0xdeadbee;
7127     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7129     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7130     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7131
7132     state = 0xdeadbee;
7133     action = 0xdeadbee;
7134     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7136     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7137     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7138
7139     state = 0xdeadbee;
7140     action = 0xdeadbee;
7141     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7143     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7144     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7145
7146     state = 0xdeadbee;
7147     action = 0xdeadbee;
7148     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7150     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7151     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7152
7153     state = 0xdeadbee;
7154     action = 0xdeadbee;
7155     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7157     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7158     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7159
7160     state = 0xdeadbee;
7161     action = 0xdeadbee;
7162     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7164     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7165     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7166
7167     state = 0xdeadbee;
7168     action = 0xdeadbee;
7169     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7171     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7172     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7173
7174     state = 0xdeadbee;
7175     action = 0xdeadbee;
7176     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7177     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7178     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7179     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7180
7181     state = 0xdeadbee;
7182     action = 0xdeadbee;
7183     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7184     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7185     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7186     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7187
7188     state = 0xdeadbee;
7189     action = 0xdeadbee;
7190     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7191     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7192     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7193     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7194
7195     state = 0xdeadbee;
7196     action = 0xdeadbee;
7197     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7198     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7199     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7200     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7201
7202     state = 0xdeadbee;
7203     action = 0xdeadbee;
7204     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7205     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7206     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7207     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7208
7209     state = 0xdeadbee;
7210     action = 0xdeadbee;
7211     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7212     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7213     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7214     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7215
7216     state = 0xdeadbee;
7217     action = 0xdeadbee;
7218     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7219     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7220     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7221     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7222
7223     state = 0xdeadbee;
7224     action = 0xdeadbee;
7225     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7226     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7227     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7228     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7229
7230     state = 0xdeadbee;
7231     action = 0xdeadbee;
7232     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7233     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7234     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7235     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7236
7237     state = 0xdeadbee;
7238     action = 0xdeadbee;
7239     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7240     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7241     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7242     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7243
7244     state = 0xdeadbee;
7245     action = 0xdeadbee;
7246     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7247     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7248     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7249     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7250
7251     state = 0xdeadbee;
7252     action = 0xdeadbee;
7253     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7254     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7255     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7256     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7257
7258     state = 0xdeadbee;
7259     action = 0xdeadbee;
7260     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7261     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7262     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7263     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7264
7265     state = 0xdeadbee;
7266     action = 0xdeadbee;
7267     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7268     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7269     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7270     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7271
7272     state = 0xdeadbee;
7273     action = 0xdeadbee;
7274     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7275     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7276     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7277     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7278
7279     state = 0xdeadbee;
7280     action = 0xdeadbee;
7281     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7282     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7283     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7284     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7285
7286     state = 0xdeadbee;
7287     action = 0xdeadbee;
7288     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7289     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7290     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7291     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7292
7293     state = 0xdeadbee;
7294     action = 0xdeadbee;
7295     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7296     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7297     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7298     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7299
7300     state = 0xdeadbee;
7301     action = 0xdeadbee;
7302     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7303     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7304     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7305     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7306
7307     MsiCloseHandle(hpkg);
7308
7309     /* uninstall the product */
7310     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7311     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7312
7313     DeleteFileA(msifile);
7314     DeleteFileA(msifile2);
7315     DeleteFileA(msifile3);
7316     DeleteFileA(msifile4);
7317 }
7318
7319 static void test_getproperty(void)
7320 {
7321     MSIHANDLE hPackage = 0;
7322     char prop[100];
7323     static CHAR empty[] = "";
7324     DWORD size;
7325     UINT r;
7326
7327     r = package_from_db(create_package_db(), &hPackage);
7328     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7329     {
7330         skip("Not enough rights to perform tests\n");
7331         DeleteFile(msifile);
7332         return;
7333     }
7334     ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
7335
7336     /* set the property */
7337     r = MsiSetProperty(hPackage, "Name", "Value");
7338     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7339
7340     /* retrieve the size, NULL pointer */
7341     size = 0;
7342     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7343     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7344     ok( size == 5, "Expected 5, got %d\n", size);
7345
7346     /* retrieve the size, empty string */
7347     size = 0;
7348     r = MsiGetProperty(hPackage, "Name", empty, &size);
7349     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7350     ok( size == 5, "Expected 5, got %d\n", size);
7351
7352     /* don't change size */
7353     r = MsiGetProperty(hPackage, "Name", prop, &size);
7354     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7355     ok( size == 5, "Expected 5, got %d\n", size);
7356     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7357
7358     /* increase the size by 1 */
7359     size++;
7360     r = MsiGetProperty(hPackage, "Name", prop, &size);
7361     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7362     ok( size == 5, "Expected 5, got %d\n", size);
7363     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7364
7365     r = MsiCloseHandle( hPackage);
7366     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7367     DeleteFile(msifile);
7368 }
7369
7370 static void test_removefiles(void)
7371 {
7372     MSIHANDLE hpkg;
7373     UINT r;
7374     MSIHANDLE hdb;
7375
7376     hdb = create_package_db();
7377     ok ( hdb, "failed to create package database\n" );
7378
7379     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7380     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7381
7382     r = create_feature_table( hdb );
7383     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7384
7385     r = create_component_table( hdb );
7386     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7387
7388     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7389     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7390
7391     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7392     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7393
7394     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7395     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7396
7397     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7398     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7399
7400     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7401     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7402
7403     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7404     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7405
7406     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7407     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7408
7409     r = create_feature_components_table( hdb );
7410     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7411
7412     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7413     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7414
7415     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7416     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7417
7418     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7419     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7420
7421     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7422     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7423
7424     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7425     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7426
7427     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7428     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7429
7430     r = create_file_table( hdb );
7431     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7432
7433     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7434     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7435
7436     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7437     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7438
7439     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7440     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7441
7442     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7443     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7444
7445     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7446     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7447
7448     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7449     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7450
7451     r = create_remove_file_table( hdb );
7452     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7453
7454     r = package_from_db( hdb, &hpkg );
7455     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7456     {
7457         skip("Not enough rights to perform tests\n");
7458         DeleteFile(msifile);
7459         return;
7460     }
7461     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7462
7463     MsiCloseHandle( hdb );
7464
7465     create_test_file( "hydrogen.txt" );
7466     create_test_file( "helium.txt" );
7467     create_test_file( "lithium.txt" );
7468     create_test_file( "beryllium.txt" );
7469     create_test_file( "boron.txt" );
7470     create_test_file( "carbon.txt" );
7471
7472     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7473     ok( r == ERROR_SUCCESS, "set property failed\n");
7474
7475     r = MsiDoAction( hpkg, "CostInitialize");
7476     ok( r == ERROR_SUCCESS, "cost init failed\n");
7477
7478     r = MsiDoAction( hpkg, "FileCost");
7479     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7480
7481     r = MsiDoAction( hpkg, "CostFinalize");
7482     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7483
7484     r = MsiDoAction( hpkg, "InstallValidate");
7485     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7486
7487     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7488     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7489
7490     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7491     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7492
7493     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7494     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7495
7496     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7497     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7498
7499     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7500     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7501
7502     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7503     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7504
7505     r = MsiDoAction( hpkg, "RemoveFiles");
7506     ok( r == ERROR_SUCCESS, "remove files failed\n");
7507
7508     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7509     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7510     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7511     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7512     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7513     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7514
7515     MsiCloseHandle( hpkg );
7516     DeleteFileA(msifile);
7517 }
7518
7519 static void test_appsearch(void)
7520 {
7521     MSIHANDLE hpkg;
7522     UINT r;
7523     MSIHANDLE hdb;
7524     CHAR prop[MAX_PATH];
7525     DWORD size;
7526
7527     hdb = create_package_db();
7528     ok ( hdb, "failed to create package database\n" );
7529
7530     r = create_appsearch_table( hdb );
7531     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7532
7533     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7534     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7535
7536     r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
7537     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7538
7539     r = create_reglocator_table( hdb );
7540     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7541
7542     r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
7543     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7544
7545     r = create_drlocator_table( hdb );
7546     ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
7547
7548     r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
7549     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7550
7551     r = create_signature_table( hdb );
7552     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7553
7554     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7555     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7556
7557     r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
7558     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7559
7560     r = package_from_db( hdb, &hpkg );
7561     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7562     {
7563         skip("Not enough rights to perform tests\n");
7564         DeleteFile(msifile);
7565         return;
7566     }
7567     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7568     MsiCloseHandle( hdb );
7569     if (r != ERROR_SUCCESS)
7570         goto done;
7571
7572     r = MsiDoAction( hpkg, "AppSearch" );
7573     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7574
7575     size = sizeof(prop);
7576     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7577     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7578     todo_wine
7579     {
7580         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7581     }
7582
7583     size = sizeof(prop);
7584     r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
7585     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7586
7587 done:
7588     MsiCloseHandle( hpkg );
7589     DeleteFileA(msifile);
7590 }
7591
7592 static void test_appsearch_complocator(void)
7593 {
7594     MSIHANDLE hpkg, hdb;
7595     CHAR path[MAX_PATH];
7596     CHAR prop[MAX_PATH];
7597     LPSTR usersid;
7598     DWORD size;
7599     UINT r;
7600
7601     if (!get_user_sid(&usersid))
7602         return;
7603
7604     if (is_process_limited())
7605     {
7606         skip("process is limited\n");
7607         return;
7608     }
7609
7610     create_test_file("FileName1");
7611     create_test_file("FileName4");
7612     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
7613                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
7614
7615     create_test_file("FileName2");
7616     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
7617                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
7618
7619     create_test_file("FileName3");
7620     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
7621                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
7622
7623     create_test_file("FileName5");
7624     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
7625                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
7626
7627     create_test_file("FileName6");
7628     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
7629                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
7630
7631     create_test_file("FileName7");
7632     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
7633                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
7634
7635     /* dir is FALSE, but we're pretending it's a directory */
7636     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
7637                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
7638
7639     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7640     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
7641                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
7642
7643     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7644     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
7645                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
7646
7647     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7648     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
7649                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
7650
7651     hdb = create_package_db();
7652     ok(hdb, "Expected a valid database handle\n");
7653
7654     r = create_appsearch_table(hdb);
7655     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7656
7657     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7659
7660     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
7661     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7662
7663     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
7664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7665
7666     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
7667     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7668
7669     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
7670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7671
7672     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
7673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7674
7675     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
7676     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7677
7678     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
7679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7680
7681     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
7682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7683
7684     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
7685     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7686
7687     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
7688     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7689
7690     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
7691     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7692
7693     r = create_complocator_table(hdb);
7694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7695
7696     /* published component, machine, file, signature, misdbLocatorTypeFile */
7697     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
7698     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7699
7700     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
7701     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
7702     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7703
7704     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
7705     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
7706     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7707
7708     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
7709     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
7710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7711
7712     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
7713     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
7714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7715
7716     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
7717     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
7718     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7719
7720     /* published component, machine, file, no signature, misdbLocatorTypeFile */
7721     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
7722     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7723
7724     /* unpublished component, no signature, misdbLocatorTypeDir */
7725     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
7726     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7727
7728     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
7729     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
7730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7731
7732     /* published component, signature w/ ver, misdbLocatorTypeFile */
7733     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
7734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7735
7736     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
7737     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
7738     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7739
7740     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
7741     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
7742     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7743
7744     r = create_signature_table(hdb);
7745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7746
7747     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
7748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7749
7750     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
7751     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7752
7753     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
7754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7755
7756     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
7757     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7758
7759     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
7760     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7761
7762     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7763     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7764
7765     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7767
7768     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
7769     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7770
7771     r = package_from_db(hdb, &hpkg);
7772     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7773     {
7774         skip("Not enough rights to perform tests\n");
7775         goto error;
7776     }
7777     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
7778
7779     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
7780     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7781
7782     r = MsiDoAction(hpkg, "AppSearch");
7783     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7784
7785     size = MAX_PATH;
7786     sprintf(path, "%s\\FileName1", CURR_DIR);
7787     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
7788     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7789     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7790
7791     size = MAX_PATH;
7792     sprintf(path, "%s\\FileName2", CURR_DIR);
7793     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
7794     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7795     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7796
7797     size = MAX_PATH;
7798     sprintf(path, "%s\\FileName3", CURR_DIR);
7799     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
7800     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7801     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7802
7803     size = MAX_PATH;
7804     sprintf(path, "%s\\FileName4", CURR_DIR);
7805     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
7806     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7807     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7808
7809     size = MAX_PATH;
7810     sprintf(path, "%s\\FileName5", CURR_DIR);
7811     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
7812     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7813     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7814
7815     size = MAX_PATH;
7816     sprintf(path, "%s\\", CURR_DIR);
7817     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
7818     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7819     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7820
7821     size = MAX_PATH;
7822     sprintf(path, "%s\\", CURR_DIR);
7823     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
7824     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7825     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7826
7827     size = MAX_PATH;
7828     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
7829     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7830     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
7831
7832     size = MAX_PATH;
7833     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
7834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7835     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7836
7837     size = MAX_PATH;
7838     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
7839     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
7840     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7841     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7842
7843     size = MAX_PATH;
7844     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
7845     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7846     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7847
7848     size = MAX_PATH;
7849     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
7850     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
7851     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7852     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7853
7854     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
7855                           MSIINSTALLCONTEXT_MACHINE, NULL);
7856     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
7857                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
7858     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
7859                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
7860     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
7861                           MSIINSTALLCONTEXT_MACHINE, NULL);
7862     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
7863                           MSIINSTALLCONTEXT_MACHINE, NULL);
7864     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
7865                           MSIINSTALLCONTEXT_MACHINE, NULL);
7866     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
7867                           MSIINSTALLCONTEXT_MACHINE, NULL);
7868     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
7869                           MSIINSTALLCONTEXT_MACHINE, NULL);
7870     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
7871                           MSIINSTALLCONTEXT_MACHINE, NULL);
7872     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
7873                           MSIINSTALLCONTEXT_MACHINE, NULL);
7874
7875     MsiCloseHandle(hpkg);
7876
7877 error:
7878     DeleteFileA("FileName1");
7879     DeleteFileA("FileName2");
7880     DeleteFileA("FileName3");
7881     DeleteFileA("FileName4");
7882     DeleteFileA("FileName5");
7883     DeleteFileA("FileName6");
7884     DeleteFileA("FileName7");
7885     DeleteFileA("FileName8.dll");
7886     DeleteFileA("FileName9.dll");
7887     DeleteFileA("FileName10.dll");
7888     DeleteFileA(msifile);
7889     LocalFree(usersid);
7890 }
7891
7892 static void test_appsearch_reglocator(void)
7893 {
7894     MSIHANDLE hpkg, hdb;
7895     CHAR path[MAX_PATH], prop[MAX_PATH];
7896     DWORD binary[2], size, val;
7897     BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
7898     HKEY hklm, classes, hkcu, users;
7899     LPSTR pathdata, pathvar, ptr;
7900     LPCSTR str;
7901     LONG res;
7902     UINT r, type = 0;
7903
7904     version = TRUE;
7905     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
7906         version = FALSE;
7907
7908     DeleteFileA("test.dll");
7909
7910     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
7911     if (res == ERROR_ACCESS_DENIED)
7912     {
7913         skip("Not enough rights to perform tests\n");
7914         return;
7915     }
7916     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7917
7918     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
7919                          (const BYTE *)"regszdata", 10);
7920     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7921
7922     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
7923     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7924
7925     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
7926                          (const BYTE *)"regszdata", 10);
7927     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7928
7929     users = 0;
7930     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
7931     ok(res == ERROR_SUCCESS ||
7932        broken(res == ERROR_INVALID_PARAMETER),
7933        "Expected ERROR_SUCCESS, got %d\n", res);
7934
7935     if (res == ERROR_SUCCESS)
7936     {
7937         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
7938                              (const BYTE *)"regszdata", 10);
7939         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7940     }
7941
7942     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
7943     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7944
7945     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
7946     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7947
7948     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
7949                          (const BYTE *)"regszdata", 10);
7950     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7951
7952     val = 42;
7953     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
7954                          (const BYTE *)&val, sizeof(DWORD));
7955     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7956
7957     val = -42;
7958     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
7959                          (const BYTE *)&val, sizeof(DWORD));
7960     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7961
7962     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
7963                          (const BYTE *)"%PATH%", 7);
7964     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7965
7966     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
7967                          (const BYTE *)"my%NOVAR%", 10);
7968     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7969
7970     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
7971                          (const BYTE *)"one\0two\0", 9);
7972     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7973
7974     binary[0] = 0x1234abcd;
7975     binary[1] = 0x567890ef;
7976     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
7977                          (const BYTE *)binary, sizeof(binary));
7978     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7979
7980     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
7981                          (const BYTE *)"#regszdata", 11);
7982     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7983
7984     create_test_file("FileName1");
7985     sprintf(path, "%s\\FileName1", CURR_DIR);
7986     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
7987                          (const BYTE *)path, lstrlenA(path) + 1);
7988     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7989
7990     sprintf(path, "%s\\FileName2", CURR_DIR);
7991     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
7992                          (const BYTE *)path, lstrlenA(path) + 1);
7993     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7994
7995     lstrcpyA(path, CURR_DIR);
7996     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
7997                          (const BYTE *)path, lstrlenA(path) + 1);
7998     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7999
8000     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
8001                          (const BYTE *)"", 1);
8002     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8003
8004     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8005     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8006     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
8007                          (const BYTE *)path, lstrlenA(path) + 1);
8008     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8009
8010     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8011     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8012     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
8013                          (const BYTE *)path, lstrlenA(path) + 1);
8014     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8015
8016     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8017     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8018     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
8019                          (const BYTE *)path, lstrlenA(path) + 1);
8020     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8021
8022     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
8023     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
8024                          (const BYTE *)path, lstrlenA(path) + 1);
8025
8026     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
8027     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
8028     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
8029                          (const BYTE *)path, lstrlenA(path) + 1);
8030
8031     hdb = create_package_db();
8032     ok(hdb, "Expected a valid database handle\n");
8033
8034     r = create_appsearch_table(hdb);
8035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8036
8037     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8039
8040     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8042
8043     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8045
8046     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8048
8049     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8050     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8051
8052     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8054
8055     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8056     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8057
8058     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8060
8061     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8062     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8063
8064     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8066
8067     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8068     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8069
8070     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8071     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8072
8073     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8074     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8075
8076     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
8077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8078
8079     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
8080     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8081
8082     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
8083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8084
8085     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
8086     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8087
8088     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
8089     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8090
8091     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
8092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8093
8094     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
8095     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8096
8097     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
8098     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8099
8100     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
8101     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8102
8103     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
8104     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8105
8106     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
8107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8108
8109     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
8110     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8111
8112     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
8113     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8114
8115     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
8116     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8117
8118     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
8119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8120
8121     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
8122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8123
8124     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
8125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8126
8127     r = create_reglocator_table(hdb);
8128     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8129
8130     type = msidbLocatorTypeRawValue;
8131     if (is_64bit)
8132         type |= msidbLocatorType64bit;
8133
8134     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
8135     r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
8136     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8137
8138     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
8139     r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
8140     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8141
8142     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
8143     r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
8144     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8145
8146     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8147     r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
8148     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8149
8150     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8151     r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
8152     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8153
8154     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
8155     r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
8156     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8157
8158     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
8159     r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
8160     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8161
8162     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
8163     r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
8164     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8165
8166     type = msidbLocatorTypeFileName;
8167     if (is_64bit)
8168         type |= msidbLocatorType64bit;
8169
8170     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
8171     r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
8172     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8173
8174     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
8175     r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
8176     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8177
8178     /* HKLM, msidbLocatorTypeFileName, no signature */
8179     r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
8180     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8181
8182     type = msidbLocatorTypeDirectory;
8183     if (is_64bit)
8184         type |= msidbLocatorType64bit;
8185
8186     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
8187     r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
8188     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8189
8190     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
8191     r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
8192     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8193
8194     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
8195     r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
8196     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8197
8198     type = msidbLocatorTypeRawValue;
8199     if (is_64bit)
8200         type |= msidbLocatorType64bit;
8201
8202     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
8203     r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
8204     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8205
8206     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
8207     r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
8208     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8209
8210     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
8211     r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
8212     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8213
8214     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
8215     r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
8216     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8217
8218     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
8219     r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
8220     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8221
8222     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
8223     r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
8224     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8225
8226     type = msidbLocatorTypeFileName;
8227     if (is_64bit)
8228         type |= msidbLocatorType64bit;
8229
8230     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
8231     r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
8232     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8233
8234     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
8235     r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
8236     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8237
8238     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
8239     r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
8240     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8241
8242     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
8243     r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
8244     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8245
8246     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
8247     r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
8248     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8249
8250     type = msidbLocatorTypeDirectory;
8251     if (is_64bit)
8252         type |= msidbLocatorType64bit;
8253
8254     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8255     r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
8256     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8257
8258     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8259     r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
8260     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8261
8262     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8263     r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
8264     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8265
8266     type = msidbLocatorTypeFileName;
8267     if (is_64bit)
8268         type |= msidbLocatorType64bit;
8269
8270     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8271     r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
8272     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8273
8274     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8275     r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
8276     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8277
8278     r = create_signature_table(hdb);
8279     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8280
8281     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8282     r = add_signature_entry(hdb, str);
8283     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8284
8285     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8286     r = add_signature_entry(hdb, str);
8287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8288
8289     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8290     r = add_signature_entry(hdb, str);
8291     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8292
8293     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8294     r = add_signature_entry(hdb, str);
8295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8296
8297     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8298     r = add_signature_entry(hdb, str);
8299     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8300
8301     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8302     r = add_signature_entry(hdb, str);
8303     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8304
8305     ptr = strrchr(CURR_DIR, '\\') + 1;
8306     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8307     r = add_signature_entry(hdb, path);
8308     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8309
8310     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8311     r = add_signature_entry(hdb, str);
8312     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8313
8314     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8315     r = add_signature_entry(hdb, str);
8316     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8317
8318     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8319     r = add_signature_entry(hdb, str);
8320     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8321
8322     r = package_from_db(hdb, &hpkg);
8323     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8324
8325     r = MsiDoAction(hpkg, "AppSearch");
8326     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8327
8328     size = MAX_PATH;
8329     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8330     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8331     ok(!lstrcmpA(prop, "regszdata"),
8332        "Expected \"regszdata\", got \"%s\"\n", prop);
8333
8334     size = MAX_PATH;
8335     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8336     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8337     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8338
8339     size = MAX_PATH;
8340     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8341     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8342     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8343
8344     size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8345     if (size == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
8346     {
8347         /* Workaround for Win95 */
8348         CHAR tempbuf[1];
8349         size = ExpandEnvironmentStringsA("%PATH%", tempbuf, 0);
8350     }
8351     pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8352     ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8353
8354     size = 0;
8355     r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8356     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8357
8358     pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8359     r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8360     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8361     ok(!lstrcmpA(pathdata, pathvar),
8362        "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8363
8364     HeapFree(GetProcessHeap(), 0, pathvar);
8365     HeapFree(GetProcessHeap(), 0, pathdata);
8366
8367     size = MAX_PATH;
8368     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8369     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8370     ok(!lstrcmpA(prop,
8371        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8372
8373     size = MAX_PATH;
8374     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8375     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8376     todo_wine
8377     {
8378         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8379            "Expected \"\\0one\\0two\\0\\0\"\n");
8380     }
8381
8382     size = MAX_PATH;
8383     lstrcpyA(path, "#xCDAB3412EF907856");
8384     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8385     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8386     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8387
8388     size = MAX_PATH;
8389     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8390     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8391     ok(!lstrcmpA(prop, "##regszdata"),
8392        "Expected \"##regszdata\", got \"%s\"\n", prop);
8393
8394     size = MAX_PATH;
8395     sprintf(path, "%s\\FileName1", CURR_DIR);
8396     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8398     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8399
8400     size = MAX_PATH;
8401     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8402     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8403     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8404
8405     size = MAX_PATH;
8406     sprintf(path, "%s\\", CURR_DIR);
8407     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8409     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8410
8411     size = MAX_PATH;
8412     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8414     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8415
8416     size = MAX_PATH;
8417     sprintf(path, "%s\\", CURR_DIR);
8418     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
8419     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8420     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8421
8422     size = MAX_PATH;
8423     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
8424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8425     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8426
8427     size = MAX_PATH;
8428     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8429     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8430     ok(!lstrcmpA(prop, "regszdata"),
8431        "Expected \"regszdata\", got \"%s\"\n", prop);
8432
8433     size = MAX_PATH;
8434     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8436     ok(!lstrcmpA(prop, "regszdata"),
8437        "Expected \"regszdata\", got \"%s\"\n", prop);
8438
8439     if (users)
8440     {
8441         size = MAX_PATH;
8442         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8443         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8444         ok(!lstrcmpA(prop, "regszdata"),
8445            "Expected \"regszdata\", got \"%s\"\n", prop);
8446     }
8447
8448     size = MAX_PATH;
8449     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8451     ok(!lstrcmpA(prop, "defvalue"),
8452        "Expected \"defvalue\", got \"%s\"\n", prop);
8453
8454     size = MAX_PATH;
8455     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8457     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8458
8459     size = MAX_PATH;
8460     r = MsiGetPropertyA(hpkg, "SIGPROP20", 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     if (version)
8465     {
8466         size = MAX_PATH;
8467         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8468         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8469         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8470         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8471
8472         size = MAX_PATH;
8473         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8474         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8475         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8476
8477         size = MAX_PATH;
8478         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8479         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8480         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8481         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8482     }
8483
8484     size = MAX_PATH;
8485     lstrcpyA(path, CURR_DIR);
8486     ptr = strrchr(path, '\\') + 1;
8487     *ptr = '\0';
8488     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8490     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8491
8492     size = MAX_PATH;
8493     sprintf(path, "%s\\", CURR_DIR);
8494     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8496     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8497
8498     size = MAX_PATH;
8499     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8501     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8502
8503     size = MAX_PATH;
8504     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8506     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8507
8508     size = MAX_PATH;
8509     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8511     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8512
8513     size = MAX_PATH;
8514     sprintf(path, "%s\\FileName1", CURR_DIR);
8515     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8517     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8518
8519     size = MAX_PATH;
8520     sprintf(path, "%s\\FileName1", CURR_DIR);
8521     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8523     if (space)
8524         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8525     else
8526         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8527
8528     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8529     RegDeleteValueA(hklm, "Value1");
8530     RegDeleteValueA(hklm, "Value2");
8531     RegDeleteValueA(hklm, "Value3");
8532     RegDeleteValueA(hklm, "Value4");
8533     RegDeleteValueA(hklm, "Value5");
8534     RegDeleteValueA(hklm, "Value6");
8535     RegDeleteValueA(hklm, "Value7");
8536     RegDeleteValueA(hklm, "Value8");
8537     RegDeleteValueA(hklm, "Value9");
8538     RegDeleteValueA(hklm, "Value10");
8539     RegDeleteValueA(hklm, "Value11");
8540     RegDeleteValueA(hklm, "Value12");
8541     RegDeleteValueA(hklm, "Value13");
8542     RegDeleteValueA(hklm, "Value14");
8543     RegDeleteValueA(hklm, "Value15");
8544     RegDeleteValueA(hklm, "Value16");
8545     RegDeleteValueA(hklm, "Value17");
8546     RegDeleteKey(hklm, "");
8547     RegCloseKey(hklm);
8548
8549     RegDeleteValueA(classes, "Value1");
8550     RegDeleteKeyA(classes, "");
8551     RegCloseKey(classes);
8552
8553     RegDeleteValueA(hkcu, "Value1");
8554     RegDeleteKeyA(hkcu, "");
8555     RegCloseKey(hkcu);
8556
8557     RegDeleteValueA(users, "Value1");
8558     RegDeleteKeyA(users, "");
8559     RegCloseKey(users);
8560
8561     DeleteFileA("FileName1");
8562     DeleteFileA("FileName3.dll");
8563     DeleteFileA("FileName4.dll");
8564     DeleteFileA("FileName5.dll");
8565     MsiCloseHandle(hpkg);
8566     DeleteFileA(msifile);
8567 }
8568
8569 static void delete_win_ini(LPCSTR file)
8570 {
8571     CHAR path[MAX_PATH];
8572
8573     GetWindowsDirectoryA(path, MAX_PATH);
8574     lstrcatA(path, "\\");
8575     lstrcatA(path, file);
8576
8577     DeleteFileA(path);
8578 }
8579
8580 static void test_appsearch_inilocator(void)
8581 {
8582     MSIHANDLE hpkg, hdb;
8583     CHAR path[MAX_PATH];
8584     CHAR prop[MAX_PATH];
8585     BOOL version;
8586     LPCSTR str;
8587     LPSTR ptr;
8588     DWORD size;
8589     UINT r;
8590
8591     version = TRUE;
8592     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8593         version = FALSE;
8594
8595     DeleteFileA("test.dll");
8596
8597     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
8598
8599     create_test_file("FileName1");
8600     sprintf(path, "%s\\FileName1", CURR_DIR);
8601     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
8602
8603     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
8604
8605     sprintf(path, "%s\\IDontExist", CURR_DIR);
8606     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
8607
8608     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8609     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8610     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
8611
8612     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8613     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8614     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
8615
8616     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8617     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8618     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
8619
8620     hdb = create_package_db();
8621     ok(hdb, "Expected a valid database handle\n");
8622
8623     r = create_appsearch_table(hdb);
8624     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8625
8626     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8627     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8628
8629     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8630     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8631
8632     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8633     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8634
8635     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8636     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8637
8638     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8639     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8640
8641     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8643
8644     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8645     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8646
8647     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8649
8650     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8651     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8652
8653     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8654     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8655
8656     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8657     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8658
8659     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8660     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8661
8662     r = create_inilocator_table(hdb);
8663     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8664
8665     /* msidbLocatorTypeRawValue, field 1 */
8666     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
8667     r = add_inilocator_entry(hdb, str);
8668     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8669
8670     /* msidbLocatorTypeRawValue, field 2 */
8671     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
8672     r = add_inilocator_entry(hdb, str);
8673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8674
8675     /* msidbLocatorTypeRawValue, entire field */
8676     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
8677     r = add_inilocator_entry(hdb, str);
8678     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8679
8680     /* msidbLocatorTypeFile */
8681     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8682     r = add_inilocator_entry(hdb, str);
8683     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8684
8685     /* msidbLocatorTypeDirectory, file */
8686     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
8687     r = add_inilocator_entry(hdb, str);
8688     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8689
8690     /* msidbLocatorTypeDirectory, directory */
8691     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
8692     r = add_inilocator_entry(hdb, str);
8693     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8694
8695     /* msidbLocatorTypeFile, file, no signature */
8696     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
8697     r = add_inilocator_entry(hdb, str);
8698     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8699
8700     /* msidbLocatorTypeFile, dir, no signature */
8701     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
8702     r = add_inilocator_entry(hdb, str);
8703     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8704
8705     /* msidbLocatorTypeFile, file does not exist */
8706     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
8707     r = add_inilocator_entry(hdb, str);
8708     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8709
8710     /* msidbLocatorTypeFile, signature with version */
8711     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
8712     r = add_inilocator_entry(hdb, str);
8713     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8714
8715     /* msidbLocatorTypeFile, signature with version, ver > max */
8716     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
8717     r = add_inilocator_entry(hdb, str);
8718     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8719
8720     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
8721     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
8722     r = add_inilocator_entry(hdb, str);
8723     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8724
8725     r = create_signature_table(hdb);
8726     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8727
8728     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
8729     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8730
8731     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
8732     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8733
8734     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8735     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8736
8737     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8738     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8739
8740     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8741     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8742
8743     r = package_from_db(hdb, &hpkg);
8744     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8745     {
8746         skip("Not enough rights to perform tests\n");
8747         goto error;
8748     }
8749     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8750
8751     r = MsiDoAction(hpkg, "AppSearch");
8752     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8753
8754     size = MAX_PATH;
8755     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8756     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8757     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
8758
8759     size = MAX_PATH;
8760     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8761     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8762     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
8763
8764     size = MAX_PATH;
8765     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8767     ok(!lstrcmpA(prop, "keydata,field2"),
8768        "Expected \"keydata,field2\", got \"%s\"\n", prop);
8769
8770     size = MAX_PATH;
8771     sprintf(path, "%s\\FileName1", CURR_DIR);
8772     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8773     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8774     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8775
8776     size = MAX_PATH;
8777     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8779     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8780
8781     size = MAX_PATH;
8782     sprintf(path, "%s\\", CURR_DIR);
8783     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8784     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8785     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8786
8787     size = MAX_PATH;
8788     sprintf(path, "%s\\", CURR_DIR);
8789     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8791     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8792
8793     size = MAX_PATH;
8794     lstrcpyA(path, CURR_DIR);
8795     ptr = strrchr(path, '\\');
8796     *(ptr + 1) = '\0';
8797     r = MsiGetPropertyA(hpkg, "SIGPROP8", 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, "SIGPROP9", 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     if (version)
8807     {
8808         size = MAX_PATH;
8809         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8810         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8811         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8812         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8813
8814         size = MAX_PATH;
8815         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8816         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8817         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8818
8819         size = MAX_PATH;
8820         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8821         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8822         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8823         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8824     }
8825
8826     MsiCloseHandle(hpkg);
8827
8828 error:
8829     delete_win_ini("IniFile.ini");
8830     DeleteFileA("FileName1");
8831     DeleteFileA("FileName2.dll");
8832     DeleteFileA("FileName3.dll");
8833     DeleteFileA("FileName4.dll");
8834     DeleteFileA(msifile);
8835 }
8836
8837 /*
8838  * MSI AppSearch action on DrLocator table always returns absolute paths.
8839  * If a relative path was set, it returns the first absolute path that
8840  * matches or an empty string if it didn't find anything.
8841  * This helper function replicates this behaviour.
8842  */
8843 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
8844 {
8845     int i, size;
8846     DWORD attr, drives;
8847
8848     size = lstrlenA(relative);
8849     drives = GetLogicalDrives();
8850     lstrcpyA(absolute, "A:\\");
8851     for (i = 0; i < 26; absolute[0] = '\0', i++)
8852     {
8853         if (!(drives & (1 << i)))
8854             continue;
8855
8856         absolute[0] = 'A' + i;
8857         if (GetDriveType(absolute) != DRIVE_FIXED)
8858             continue;
8859
8860         lstrcpynA(absolute + 3, relative, size + 1);
8861         attr = GetFileAttributesA(absolute);
8862         if (attr != INVALID_FILE_ATTRIBUTES &&
8863             (attr & FILE_ATTRIBUTE_DIRECTORY))
8864         {
8865             if (absolute[3 + size - 1] != '\\')
8866                 lstrcatA(absolute, "\\");
8867             break;
8868         }
8869         absolute[3] = '\0';
8870     }
8871 }
8872
8873 static void test_appsearch_drlocator(void)
8874 {
8875     MSIHANDLE hpkg, hdb;
8876     CHAR path[MAX_PATH];
8877     CHAR prop[MAX_PATH];
8878     BOOL version;
8879     LPCSTR str;
8880     DWORD size;
8881     UINT r;
8882
8883     version = TRUE;
8884     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8885         version = FALSE;
8886
8887     DeleteFileA("test.dll");
8888
8889     create_test_file("FileName1");
8890     CreateDirectoryA("one", NULL);
8891     CreateDirectoryA("one\\two", NULL);
8892     CreateDirectoryA("one\\two\\three", NULL);
8893     create_test_file("one\\two\\three\\FileName2");
8894     CreateDirectoryA("another", NULL);
8895     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8896     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8897     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8898
8899     hdb = create_package_db();
8900     ok(hdb, "Expected a valid database handle\n");
8901
8902     r = create_appsearch_table(hdb);
8903     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8904
8905     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8906     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8907
8908     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8909     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8910
8911     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8913
8914     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8916
8917     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8918     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8919
8920     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8921     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8922
8923     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8925
8926     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8927     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8928
8929     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8930     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8931
8932     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8933     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8934
8935     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8936     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8937
8938     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8939     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8940
8941     r = create_drlocator_table(hdb);
8942     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8943
8944     /* no parent, full path, depth 0, signature */
8945     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
8946     r = add_drlocator_entry(hdb, path);
8947     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8948
8949     /* no parent, full path, depth 0, no signature */
8950     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
8951     r = add_drlocator_entry(hdb, path);
8952     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8953
8954     /* no parent, relative path, depth 0, no signature */
8955     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
8956     r = add_drlocator_entry(hdb, path);
8957     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8958
8959     /* no parent, full path, depth 2, signature */
8960     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
8961     r = add_drlocator_entry(hdb, path);
8962     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8963
8964     /* no parent, full path, depth 3, signature */
8965     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
8966     r = add_drlocator_entry(hdb, path);
8967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8968
8969     /* no parent, full path, depth 1, signature is dir */
8970     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
8971     r = add_drlocator_entry(hdb, path);
8972     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8973
8974     /* parent is in DrLocator, relative path, depth 0, signature */
8975     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
8976     r = add_drlocator_entry(hdb, path);
8977     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8978
8979     /* no parent, full path, depth 0, signature w/ version */
8980     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
8981     r = add_drlocator_entry(hdb, path);
8982     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8983
8984     /* no parent, full path, depth 0, signature w/ version, ver > max */
8985     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
8986     r = add_drlocator_entry(hdb, path);
8987     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8988
8989     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
8990     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
8991     r = add_drlocator_entry(hdb, path);
8992     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8993
8994     /* no parent, relative empty path, depth 0, no signature */
8995     sprintf(path, "'NewSignature11', '', '', 0");
8996     r = add_drlocator_entry(hdb, path);
8997     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8998
8999     r = create_reglocator_table(hdb);
9000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9001
9002     /* parent */
9003     r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
9004     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9005
9006     /* parent is in RegLocator, no path, depth 0, no signature */
9007     sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
9008     r = add_drlocator_entry(hdb, path);
9009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9010
9011     r = create_signature_table(hdb);
9012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9013
9014     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
9015     r = add_signature_entry(hdb, str);
9016     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9017
9018     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
9019     r = add_signature_entry(hdb, str);
9020     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9021
9022     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
9023     r = add_signature_entry(hdb, str);
9024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9025
9026     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
9027     r = add_signature_entry(hdb, str);
9028     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9029
9030     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
9031     r = add_signature_entry(hdb, str);
9032     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9033
9034     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9035     r = add_signature_entry(hdb, str);
9036     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9037
9038     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9039     r = add_signature_entry(hdb, str);
9040     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9041
9042     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9043     r = add_signature_entry(hdb, str);
9044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9045
9046     r = package_from_db(hdb, &hpkg);
9047     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9048     {
9049         skip("Not enough rights to perform tests\n");
9050         goto error;
9051     }
9052     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9053
9054     r = MsiDoAction(hpkg, "AppSearch");
9055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9056
9057     size = MAX_PATH;
9058     sprintf(path, "%s\\FileName1", CURR_DIR);
9059     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9060     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9061     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9062
9063     size = MAX_PATH;
9064     sprintf(path, "%s\\", CURR_DIR);
9065     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9066     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9067     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9068
9069     size = MAX_PATH;
9070     search_absolute_directory(path, CURR_DIR + 3);
9071     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9072     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9073     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9074
9075     size = MAX_PATH;
9076     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9078     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9079
9080     size = MAX_PATH;
9081     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9082     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9084     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9085
9086     size = MAX_PATH;
9087     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9088     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9089     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9090
9091     size = MAX_PATH;
9092     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9093     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9094     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9095     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9096
9097     if (version)
9098     {
9099         size = MAX_PATH;
9100         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9101         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9102         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9103         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9104
9105         size = MAX_PATH;
9106         r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9107         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9108         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9109
9110         size = MAX_PATH;
9111         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9112         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9113         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9114     }
9115
9116     size = MAX_PATH;
9117     search_absolute_directory(path, "");
9118     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9120     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9121
9122     size = MAX_PATH;
9123     strcpy(path, "c:\\");
9124     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
9125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9126     ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
9127
9128     MsiCloseHandle(hpkg);
9129
9130 error:
9131     DeleteFileA("FileName1");
9132     DeleteFileA("FileName3.dll");
9133     DeleteFileA("FileName4.dll");
9134     DeleteFileA("FileName5.dll");
9135     DeleteFileA("one\\two\\three\\FileName2");
9136     RemoveDirectoryA("one\\two\\three");
9137     RemoveDirectoryA("one\\two");
9138     RemoveDirectoryA("one");
9139     RemoveDirectoryA("another");
9140     DeleteFileA(msifile);
9141 }
9142
9143 static void test_featureparents(void)
9144 {
9145     MSIHANDLE hpkg;
9146     UINT r;
9147     MSIHANDLE hdb;
9148     INSTALLSTATE state, action;
9149
9150     hdb = create_package_db();
9151     ok ( hdb, "failed to create package database\n" );
9152
9153     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
9154     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
9155
9156     r = create_feature_table( hdb );
9157     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
9158
9159     r = create_component_table( hdb );
9160     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
9161
9162     r = create_feature_components_table( hdb );
9163     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
9164
9165     r = create_file_table( hdb );
9166     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
9167
9168     /* msidbFeatureAttributesFavorLocal */
9169     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
9170     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9171
9172     /* msidbFeatureAttributesFavorSource */
9173     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
9174     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9175
9176     /* msidbFeatureAttributesFavorLocal */
9177     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
9178     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9179
9180     /* disabled because of install level */
9181     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
9182     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9183
9184     /* child feature of disabled feature */
9185     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
9186     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9187
9188     /* component of disabled feature (install level) */
9189     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
9190     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9191
9192     /* component of disabled child feature (install level) */
9193     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
9194     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9195
9196     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9197     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
9198     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9199
9200     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9201     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
9202     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9203
9204     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9205     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
9206     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9207
9208     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
9209     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
9210     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9211
9212     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
9213     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
9214     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9215
9216     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
9217     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
9218     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9219
9220     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9221     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
9222     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9223
9224     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9225     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
9226     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9227
9228     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9229     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
9230
9231     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
9232     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9233
9234     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
9235     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9236
9237     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
9238     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9239
9240     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
9241     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9242
9243     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
9244     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9245
9246     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
9247     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9248
9249     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
9250     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9251
9252     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
9253     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9254
9255     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
9256     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9257
9258     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
9259     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9260
9261     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
9262     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9263
9264     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
9265     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9266
9267     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
9268     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9269
9270     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
9271     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9272
9273     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
9274     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9275
9276     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
9277     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9278
9279     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
9280     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9281
9282     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
9283     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9284
9285     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
9286     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9287
9288     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9289     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9290
9291     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9292     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9293
9294     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9295     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9296
9297     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9298     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9299
9300     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9301     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9302
9303     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9304     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9305
9306     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9307     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9308
9309     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9310     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9311
9312     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9313     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9314
9315     r = package_from_db( hdb, &hpkg );
9316     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9317     {
9318         skip("Not enough rights to perform tests\n");
9319         DeleteFile(msifile);
9320         return;
9321     }
9322     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9323
9324     MsiCloseHandle( hdb );
9325
9326     r = MsiDoAction( hpkg, "CostInitialize");
9327     ok( r == ERROR_SUCCESS, "cost init failed\n");
9328
9329     r = MsiDoAction( hpkg, "FileCost");
9330     ok( r == ERROR_SUCCESS, "file cost failed\n");
9331
9332     r = MsiDoAction( hpkg, "CostFinalize");
9333     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9334
9335     state = 0xdeadbee;
9336     action = 0xdeadbee;
9337     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9338     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9339     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9340     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9341
9342     state = 0xdeadbee;
9343     action = 0xdeadbee;
9344     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9345     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9346     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9347     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9348
9349     state = 0xdeadbee;
9350     action = 0xdeadbee;
9351     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9352     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9353     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9354     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9355
9356     state = 0xdeadbee;
9357     action = 0xdeadbee;
9358     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9359     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9360     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9361     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9362
9363     state = 0xdeadbee;
9364     action = 0xdeadbee;
9365     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9366     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9367     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9368     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9369
9370     state = 0xdeadbee;
9371     action = 0xdeadbee;
9372     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9373     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9374     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9375     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9376
9377     state = 0xdeadbee;
9378     action = 0xdeadbee;
9379     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9380     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9381     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9382     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9383
9384     state = 0xdeadbee;
9385     action = 0xdeadbee;
9386     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9387     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9388     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9389     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9390
9391     state = 0xdeadbee;
9392     action = 0xdeadbee;
9393     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9394     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9395     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9396     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9397
9398     state = 0xdeadbee;
9399     action = 0xdeadbee;
9400     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9401     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9402     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9403     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9404
9405     state = 0xdeadbee;
9406     action = 0xdeadbee;
9407     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9408     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9409     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9410     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9411
9412     state = 0xdeadbee;
9413     action = 0xdeadbee;
9414     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9415     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9416     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9417     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9418
9419     state = 0xdeadbee;
9420     action = 0xdeadbee;
9421     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9422     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9423     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9424     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9425
9426     state = 0xdeadbee;
9427     action = 0xdeadbee;
9428     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9429     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9430     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9431     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9432
9433     state = 0xdeadbee;
9434     action = 0xdeadbee;
9435     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9436     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9437     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9438     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9439
9440     state = 0xdeadbee;
9441     action = 0xdeadbee;
9442     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9443     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9444     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9445     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9446
9447     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9448     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9449
9450     r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
9451     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
9452
9453     state = 0xdeadbee;
9454     action = 0xdeadbee;
9455     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9457     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9458     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9459
9460     state = 0xdeadbee;
9461     action = 0xdeadbee;
9462     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9464     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9465     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9466
9467     state = 0xdeadbee;
9468     action = 0xdeadbee;
9469     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9471     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9472     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9473
9474     state = 0xdeadbee;
9475     action = 0xdeadbee;
9476     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9478     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9479     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9480
9481     state = 0xdeadbee;
9482     action = 0xdeadbee;
9483     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9485     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9486     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9487
9488     state = 0xdeadbee;
9489     action = 0xdeadbee;
9490     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9492     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9493     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9494
9495     state = 0xdeadbee;
9496     action = 0xdeadbee;
9497     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9499     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9500     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9501
9502     state = 0xdeadbee;
9503     action = 0xdeadbee;
9504     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9505     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9506     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9507     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9508
9509     state = 0xdeadbee;
9510     action = 0xdeadbee;
9511     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9513     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9514     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9515
9516     state = 0xdeadbee;
9517     action = 0xdeadbee;
9518     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9520     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9521     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9522
9523     state = 0xdeadbee;
9524     action = 0xdeadbee;
9525     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9527     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9528     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9529
9530     state = 0xdeadbee;
9531     action = 0xdeadbee;
9532     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9534     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9535     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9536
9537     state = 0xdeadbee;
9538     action = 0xdeadbee;
9539     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9541     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9542     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9543
9544     state = 0xdeadbee;
9545     action = 0xdeadbee;
9546     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9548     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9549     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9550     
9551     MsiCloseHandle(hpkg);
9552     DeleteFileA(msifile);
9553 }
9554
9555 static void test_installprops(void)
9556 {
9557     MSIHANDLE hpkg, hdb;
9558     CHAR path[MAX_PATH], buf[MAX_PATH];
9559     DWORD size, type;
9560     LANGID langid;
9561     HKEY hkey1, hkey2;
9562     int res;
9563     UINT r;
9564     REGSAM access = KEY_ALL_ACCESS;
9565     BOOL wow64;
9566     SYSTEM_INFO si;
9567
9568     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
9569         access |= KEY_WOW64_64KEY;
9570
9571     GetCurrentDirectory(MAX_PATH, path);
9572     lstrcat(path, "\\");
9573     lstrcat(path, msifile);
9574
9575     hdb = create_package_db();
9576     ok( hdb, "failed to create database\n");
9577
9578     r = package_from_db(hdb, &hpkg);
9579     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9580     {
9581         skip("Not enough rights to perform tests\n");
9582         DeleteFile(msifile);
9583         return;
9584     }
9585     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9586
9587     MsiCloseHandle(hdb);
9588
9589     size = MAX_PATH;
9590     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
9591     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9592     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9593
9594     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
9595     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
9596
9597     size = MAX_PATH;
9598     type = REG_SZ;
9599     *path = '\0';
9600     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9601     {
9602         size = MAX_PATH;
9603         type = REG_SZ;
9604         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
9605     }
9606
9607     /* win9x doesn't set this */
9608     if (*path)
9609     {
9610         size = MAX_PATH;
9611         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
9612         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9613         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9614     }
9615
9616     size = MAX_PATH;
9617     type = REG_SZ;
9618     *path = '\0';
9619     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9620     {
9621         size = MAX_PATH;
9622         type = REG_SZ;
9623         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
9624     }
9625
9626     if (*path)
9627     {
9628         size = MAX_PATH;
9629         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
9630         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9631         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9632     }
9633
9634     size = MAX_PATH;
9635     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
9636     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9637     trace("VersionDatabase = %s\n", buf);
9638
9639     size = MAX_PATH;
9640     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
9641     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9642     trace("VersionMsi = %s\n", buf);
9643
9644     size = MAX_PATH;
9645     r = MsiGetProperty(hpkg, "Date", buf, &size);
9646     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9647     trace("Date = %s\n", buf);
9648
9649     size = MAX_PATH;
9650     r = MsiGetProperty(hpkg, "Time", buf, &size);
9651     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9652     trace("Time = %s\n", buf);
9653
9654     size = MAX_PATH;
9655     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
9656     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9657     trace("PackageCode = %s\n", buf);
9658
9659     langid = GetUserDefaultLangID();
9660     sprintf(path, "%d", langid);
9661
9662     size = MAX_PATH;
9663     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
9664     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
9665     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
9666
9667     res = GetSystemMetrics(SM_CXSCREEN);
9668     size = MAX_PATH;
9669     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
9670     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9671
9672     res = GetSystemMetrics(SM_CYSCREEN);
9673     size = MAX_PATH;
9674     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
9675     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
9676
9677     if (pGetSystemInfo)
9678     {
9679         pGetSystemInfo(&si);
9680         if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
9681         {
9682             buf[0] = 0;
9683             size = MAX_PATH;
9684             r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
9685             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9686             ok(buf[0], "property not set\n");
9687
9688             buf[0] = 0;
9689             size = MAX_PATH;
9690             r = MsiGetProperty(hpkg, "Msix64", buf, &size);
9691             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9692             ok(buf[0], "property not set\n");
9693
9694             buf[0] = 0;
9695             size = MAX_PATH;
9696             r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
9697             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9698             ok(buf[0], "property not set\n");
9699         }
9700     }
9701
9702     CloseHandle(hkey1);
9703     CloseHandle(hkey2);
9704     MsiCloseHandle(hpkg);
9705     DeleteFile(msifile);
9706 }
9707
9708 static void test_launchconditions(void)
9709 {
9710     MSIHANDLE hpkg;
9711     MSIHANDLE hdb;
9712     UINT r;
9713
9714     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9715
9716     hdb = create_package_db();
9717     ok( hdb, "failed to create package database\n" );
9718
9719     r = create_launchcondition_table( hdb );
9720     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
9721
9722     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
9723     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9724
9725     /* invalid condition */
9726     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
9727     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
9728
9729     r = package_from_db( hdb, &hpkg );
9730     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9731     {
9732         skip("Not enough rights to perform tests\n");
9733         DeleteFile(msifile);
9734         return;
9735     }
9736     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9737
9738     MsiCloseHandle( hdb );
9739
9740     r = MsiSetProperty( hpkg, "X", "1" );
9741     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9742
9743     /* invalid conditions are ignored */
9744     r = MsiDoAction( hpkg, "LaunchConditions" );
9745     ok( r == ERROR_SUCCESS, "cost init failed\n" );
9746
9747     /* verify LaunchConditions still does some verification */
9748     r = MsiSetProperty( hpkg, "X", "2" );
9749     ok( r == ERROR_SUCCESS, "failed to set property\n" );
9750
9751     r = MsiDoAction( hpkg, "LaunchConditions" );
9752     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
9753
9754     MsiCloseHandle( hpkg );
9755     DeleteFile( msifile );
9756 }
9757
9758 static void test_ccpsearch(void)
9759 {
9760     MSIHANDLE hdb, hpkg;
9761     CHAR prop[MAX_PATH];
9762     DWORD size = MAX_PATH;
9763     UINT r;
9764
9765     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9766
9767     hdb = create_package_db();
9768     ok(hdb, "failed to create package database\n");
9769
9770     r = create_ccpsearch_table(hdb);
9771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9772
9773     r = add_ccpsearch_entry(hdb, "'CCP_random'");
9774     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9775
9776     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
9777     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9778
9779     r = create_reglocator_table(hdb);
9780     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9781
9782     r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
9783     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9784
9785     r = create_drlocator_table(hdb);
9786     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9787
9788     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
9789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9790
9791     r = create_signature_table(hdb);
9792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9793
9794     r = package_from_db(hdb, &hpkg);
9795     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9796     {
9797         skip("Not enough rights to perform tests\n");
9798         DeleteFile(msifile);
9799         return;
9800     }
9801     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9802
9803     MsiCloseHandle(hdb);
9804
9805     r = MsiDoAction(hpkg, "CCPSearch");
9806     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9807
9808     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
9809     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9810     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
9811
9812     MsiCloseHandle(hpkg);
9813     DeleteFileA(msifile);
9814 }
9815
9816 static void test_complocator(void)
9817 {
9818     MSIHANDLE hdb, hpkg;
9819     UINT r;
9820     CHAR prop[MAX_PATH];
9821     CHAR expected[MAX_PATH];
9822     DWORD size = MAX_PATH;
9823
9824     hdb = create_package_db();
9825     ok(hdb, "failed to create package database\n");
9826
9827     r = create_appsearch_table(hdb);
9828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9829
9830     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
9831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9832
9833     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
9834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9835
9836     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
9837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9838
9839     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
9840     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9841
9842     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
9843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9844
9845     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
9846     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9847
9848     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
9849     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9850
9851     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
9852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9853
9854     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
9855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9856
9857     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
9858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9859
9860     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
9861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9862
9863     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
9864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9865
9866     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
9867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9868
9869     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
9870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9871
9872     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
9873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9874
9875     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
9876     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9877
9878     r = create_complocator_table(hdb);
9879     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9880
9881     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
9882     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9883
9884     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
9885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9886
9887     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
9888     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9889
9890     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
9891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9892
9893     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
9894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9895
9896     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
9897     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9898
9899     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
9900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9901
9902     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
9903     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9904
9905     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
9906     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9907
9908     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
9909     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9910
9911     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
9912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9913
9914     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
9915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9916
9917     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
9918     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9919
9920     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
9921     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9922
9923     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
9924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9925
9926     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
9927     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9928
9929     r = create_signature_table(hdb);
9930     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9931
9932     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
9933     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9934
9935     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
9936     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9937
9938     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
9939     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9940
9941     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
9942     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9943
9944     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
9945     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9946
9947     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
9948     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9949
9950     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
9951     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9952
9953     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
9954     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9955
9956     r = package_from_db(hdb, &hpkg);
9957     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9958     {
9959         skip("Not enough rights to perform tests\n");
9960         DeleteFile(msifile);
9961         return;
9962     }
9963     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9964
9965     MsiCloseHandle(hdb);
9966
9967     create_test_file("abelisaurus");
9968     create_test_file("bactrosaurus");
9969     create_test_file("camelotia");
9970     create_test_file("diclonius");
9971     create_test_file("echinodon");
9972     create_test_file("falcarius");
9973     create_test_file("gallimimus");
9974     create_test_file("hagryphus");
9975     CreateDirectoryA("iguanodon", NULL);
9976     CreateDirectoryA("jobaria", NULL);
9977     CreateDirectoryA("kakuru", NULL);
9978     CreateDirectoryA("labocania", NULL);
9979     CreateDirectoryA("megaraptor", NULL);
9980     CreateDirectoryA("neosodon", NULL);
9981     CreateDirectoryA("olorotitan", NULL);
9982     CreateDirectoryA("pantydraco", NULL);
9983
9984     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
9985                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
9986     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
9987                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
9988     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
9989                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
9990     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
9991                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
9992     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
9993                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
9994     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
9995                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
9996     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
9997                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
9998     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
9999                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
10000
10001     r = MsiDoAction(hpkg, "AppSearch");
10002     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10003
10004     size = MAX_PATH;
10005     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
10006     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10007
10008     lstrcpyA(expected, CURR_DIR);
10009     lstrcatA(expected, "\\abelisaurus");
10010     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10011        "Expected %s or empty string, got %s\n", expected, prop);
10012
10013     size = MAX_PATH;
10014     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", 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, "CAMELOTIA", 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, "DICLONIUS", 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, "ECHINODON", prop, &size);
10030     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10031
10032     lstrcpyA(expected, CURR_DIR);
10033     lstrcatA(expected, "\\");
10034     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10035        "Expected %s or empty string, got %s\n", expected, prop);
10036
10037     size = MAX_PATH;
10038     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
10039     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10040     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10041
10042     size = MAX_PATH;
10043     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
10044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10045     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10046
10047     size = MAX_PATH;
10048     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
10049     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10050     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10051
10052     size = MAX_PATH;
10053     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
10054     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10055     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10056
10057     size = MAX_PATH;
10058     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
10059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10060     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10061
10062     size = MAX_PATH;
10063     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
10064     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10065     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10066
10067     size = MAX_PATH;
10068     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
10069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10070     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10071
10072     size = MAX_PATH;
10073     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
10074     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10075
10076     lstrcpyA(expected, CURR_DIR);
10077     lstrcatA(expected, "\\");
10078     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10079        "Expected %s or empty string, got %s\n", expected, prop);
10080
10081     size = MAX_PATH;
10082     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
10083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10084
10085     lstrcpyA(expected, CURR_DIR);
10086     lstrcatA(expected, "\\neosodon\\");
10087     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10088        "Expected %s or empty string, got %s\n", expected, prop);
10089
10090     size = MAX_PATH;
10091     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
10092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10093     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10094
10095     size = MAX_PATH;
10096     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
10097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10098     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10099
10100     MsiCloseHandle(hpkg);
10101     DeleteFileA("abelisaurus");
10102     DeleteFileA("bactrosaurus");
10103     DeleteFileA("camelotia");
10104     DeleteFileA("diclonius");
10105     DeleteFileA("echinodon");
10106     DeleteFileA("falcarius");
10107     DeleteFileA("gallimimus");
10108     DeleteFileA("hagryphus");
10109     RemoveDirectoryA("iguanodon");
10110     RemoveDirectoryA("jobaria");
10111     RemoveDirectoryA("kakuru");
10112     RemoveDirectoryA("labocania");
10113     RemoveDirectoryA("megaraptor");
10114     RemoveDirectoryA("neosodon");
10115     RemoveDirectoryA("olorotitan");
10116     RemoveDirectoryA("pantydraco");
10117     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
10118                           MSIINSTALLCONTEXT_MACHINE, NULL);
10119     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
10120                           MSIINSTALLCONTEXT_MACHINE, NULL);
10121     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
10122                           MSIINSTALLCONTEXT_MACHINE, NULL);
10123     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
10124                           MSIINSTALLCONTEXT_MACHINE, NULL);
10125     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
10126                           MSIINSTALLCONTEXT_MACHINE, NULL);
10127     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
10128                           MSIINSTALLCONTEXT_MACHINE, NULL);
10129     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
10130                           MSIINSTALLCONTEXT_MACHINE, NULL);
10131     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
10132                           MSIINSTALLCONTEXT_MACHINE, NULL);
10133     DeleteFileA(msifile);
10134 }
10135
10136 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
10137 {
10138     MSIHANDLE summary;
10139     UINT r;
10140
10141     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
10142     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10143
10144     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
10145     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10146
10147     r = MsiSummaryInfoPersist(summary);
10148     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10149
10150     MsiCloseHandle(summary);
10151 }
10152
10153 static void test_MsiGetSourcePath(void)
10154 {
10155     MSIHANDLE hdb, hpkg;
10156     CHAR path[MAX_PATH];
10157     CHAR cwd[MAX_PATH];
10158     CHAR subsrc[MAX_PATH];
10159     CHAR sub2[MAX_PATH];
10160     DWORD size;
10161     UINT r;
10162
10163     lstrcpyA(cwd, CURR_DIR);
10164     lstrcatA(cwd, "\\");
10165
10166     lstrcpyA(subsrc, cwd);
10167     lstrcatA(subsrc, "subsource");
10168     lstrcatA(subsrc, "\\");
10169
10170     lstrcpyA(sub2, subsrc);
10171     lstrcatA(sub2, "sub2");
10172     lstrcatA(sub2, "\\");
10173
10174     /* uncompressed source */
10175
10176     hdb = create_package_db();
10177     ok( hdb, "failed to create database\n");
10178
10179     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10180
10181     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10182     ok(r == S_OK, "failed\n");
10183
10184     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
10185     ok(r == S_OK, "failed\n");
10186
10187     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
10188     ok(r == S_OK, "failed\n");
10189
10190     r = MsiDatabaseCommit(hdb);
10191     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
10192
10193     r = package_from_db(hdb, &hpkg);
10194     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10195     {
10196         skip("Not enough rights to perform tests\n");
10197         DeleteFile(msifile);
10198         return;
10199     }
10200     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10201
10202     MsiCloseHandle(hdb);
10203
10204     /* invalid database handle */
10205     size = MAX_PATH;
10206     lstrcpyA(path, "kiwi");
10207     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
10208     ok(r == ERROR_INVALID_HANDLE,
10209        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
10210     ok(!lstrcmpA(path, "kiwi"),
10211        "Expected path to be unchanged, got \"%s\"\n", path);
10212     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10213
10214     /* NULL szFolder */
10215     size = MAX_PATH;
10216     lstrcpyA(path, "kiwi");
10217     r = MsiGetSourcePath(hpkg, NULL, path, &size);
10218     ok(r == ERROR_INVALID_PARAMETER,
10219        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10220     ok(!lstrcmpA(path, "kiwi"),
10221        "Expected path to be unchanged, got \"%s\"\n", path);
10222     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10223
10224     /* empty szFolder */
10225     size = MAX_PATH;
10226     lstrcpyA(path, "kiwi");
10227     r = MsiGetSourcePath(hpkg, "", path, &size);
10228     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10229     ok(!lstrcmpA(path, "kiwi"),
10230        "Expected path to be unchanged, got \"%s\"\n", path);
10231     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10232
10233     /* try TARGETDIR */
10234     size = MAX_PATH;
10235     lstrcpyA(path, "kiwi");
10236     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10237     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10238     ok(!lstrcmpA(path, "kiwi"),
10239        "Expected path to be unchanged, got \"%s\"\n", path);
10240     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10241
10242     size = MAX_PATH;
10243     lstrcpyA(path, "kiwi");
10244     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10245     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10246     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10247     ok(size == 0, "Expected 0, got %d\n", size);
10248
10249     size = MAX_PATH;
10250     lstrcpyA(path, "kiwi");
10251     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10252     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10253     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10254     ok(size == 0, "Expected 0, got %d\n", size);
10255
10256     /* try SourceDir */
10257     size = MAX_PATH;
10258     lstrcpyA(path, "kiwi");
10259     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10260     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10261     ok(!lstrcmpA(path, "kiwi"),
10262        "Expected path to be unchanged, got \"%s\"\n", path);
10263     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10264
10265     /* try SOURCEDIR */
10266     size = MAX_PATH;
10267     lstrcpyA(path, "kiwi");
10268     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10269     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10270     ok(!lstrcmpA(path, "kiwi"),
10271        "Expected path to be unchanged, got \"%s\"\n", path);
10272     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10273
10274     /* source path does not exist, but the property exists */
10275     size = MAX_PATH;
10276     lstrcpyA(path, "kiwi");
10277     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10278     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10279     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10280     ok(size == 0, "Expected 0, got %d\n", size);
10281
10282     size = MAX_PATH;
10283     lstrcpyA(path, "kiwi");
10284     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10285     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10286     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10287     ok(size == 0, "Expected 0, got %d\n", size);
10288
10289     /* try SubDir */
10290     size = MAX_PATH;
10291     lstrcpyA(path, "kiwi");
10292     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10293     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10294     ok(!lstrcmpA(path, "kiwi"),
10295        "Expected path to be unchanged, got \"%s\"\n", path);
10296     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10297
10298     /* try SubDir2 */
10299     size = MAX_PATH;
10300     lstrcpyA(path, "kiwi");
10301     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10302     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10303     ok(!lstrcmpA(path, "kiwi"),
10304        "Expected path to be unchanged, got \"%s\"\n", path);
10305     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10306
10307     r = MsiDoAction(hpkg, "CostInitialize");
10308     ok(r == ERROR_SUCCESS, "cost init failed\n");
10309
10310     /* try TARGETDIR after CostInitialize */
10311     size = MAX_PATH;
10312     lstrcpyA(path, "kiwi");
10313     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10314     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10315     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10316     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10317
10318     /* try SourceDir after CostInitialize */
10319     size = MAX_PATH;
10320     lstrcpyA(path, "kiwi");
10321     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10322     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10323     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10324     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10325
10326     /* try SOURCEDIR after CostInitialize */
10327     size = MAX_PATH;
10328     lstrcpyA(path, "kiwi");
10329     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10330     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10331     ok(!lstrcmpA(path, "kiwi"),
10332        "Expected path to be unchanged, got \"%s\"\n", path);
10333     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10334
10335     /* source path does not exist, but the property exists */
10336     size = MAX_PATH;
10337     lstrcpyA(path, "kiwi");
10338     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10339     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10340     todo_wine
10341     {
10342         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10343         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10344     }
10345
10346     /* try SubDir after CostInitialize */
10347     size = MAX_PATH;
10348     lstrcpyA(path, "kiwi");
10349     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10350     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10351     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10352     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10353
10354     /* try SubDir2 after CostInitialize */
10355     size = MAX_PATH;
10356     lstrcpyA(path, "kiwi");
10357     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10358     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10359     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10360     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10361
10362     r = MsiDoAction(hpkg, "ResolveSource");
10363     ok(r == ERROR_SUCCESS, "file cost failed\n");
10364
10365     /* try TARGETDIR after ResolveSource */
10366     size = MAX_PATH;
10367     lstrcpyA(path, "kiwi");
10368     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10369     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10370     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10371     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10372
10373     /* try SourceDir after ResolveSource */
10374     size = MAX_PATH;
10375     lstrcpyA(path, "kiwi");
10376     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10377     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10378     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10379     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10380
10381     /* try SOURCEDIR after ResolveSource */
10382     size = MAX_PATH;
10383     lstrcpyA(path, "kiwi");
10384     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10385     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10386     ok(!lstrcmpA(path, "kiwi"),
10387        "Expected path to be unchanged, got \"%s\"\n", path);
10388     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10389
10390     /* source path does not exist, but the property exists */
10391     size = MAX_PATH;
10392     lstrcpyA(path, "kiwi");
10393     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10394     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10395     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10396     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10397
10398     /* try SubDir after ResolveSource */
10399     size = MAX_PATH;
10400     lstrcpyA(path, "kiwi");
10401     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10402     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10403     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10404     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10405
10406     /* try SubDir2 after ResolveSource */
10407     size = MAX_PATH;
10408     lstrcpyA(path, "kiwi");
10409     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10410     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10411     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10412     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10413
10414     r = MsiDoAction(hpkg, "FileCost");
10415     ok(r == ERROR_SUCCESS, "file cost failed\n");
10416
10417     /* try TARGETDIR after FileCost */
10418     size = MAX_PATH;
10419     lstrcpyA(path, "kiwi");
10420     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10421     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10422     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10423     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10424
10425     /* try SourceDir after FileCost */
10426     size = MAX_PATH;
10427     lstrcpyA(path, "kiwi");
10428     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10429     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10430     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10431     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10432
10433     /* try SOURCEDIR after FileCost */
10434     size = MAX_PATH;
10435     lstrcpyA(path, "kiwi");
10436     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10437     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10438     ok(!lstrcmpA(path, "kiwi"),
10439        "Expected path to be unchanged, got \"%s\"\n", path);
10440     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10441
10442     /* source path does not exist, but the property exists */
10443     size = MAX_PATH;
10444     lstrcpyA(path, "kiwi");
10445     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10446     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10447     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10448     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10449
10450     /* try SubDir after FileCost */
10451     size = MAX_PATH;
10452     lstrcpyA(path, "kiwi");
10453     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10455     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10456     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10457
10458     /* try SubDir2 after FileCost */
10459     size = MAX_PATH;
10460     lstrcpyA(path, "kiwi");
10461     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10463     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10464     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10465
10466     r = MsiDoAction(hpkg, "CostFinalize");
10467     ok(r == ERROR_SUCCESS, "file cost failed\n");
10468
10469     /* try TARGETDIR after CostFinalize */
10470     size = MAX_PATH;
10471     lstrcpyA(path, "kiwi");
10472     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10473     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10474     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10475     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10476
10477     /* try SourceDir after CostFinalize */
10478     size = MAX_PATH;
10479     lstrcpyA(path, "kiwi");
10480     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10481     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10482     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10483     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10484
10485     /* try SOURCEDIR after CostFinalize */
10486     size = MAX_PATH;
10487     lstrcpyA(path, "kiwi");
10488     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10489     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10490     ok(!lstrcmpA(path, "kiwi"),
10491        "Expected path to be unchanged, got \"%s\"\n", path);
10492     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10493
10494     /* source path does not exist, but the property exists */
10495     size = MAX_PATH;
10496     lstrcpyA(path, "kiwi");
10497     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10499     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10500     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10501
10502     /* try SubDir after CostFinalize */
10503     size = MAX_PATH;
10504     lstrcpyA(path, "kiwi");
10505     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10506     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10507     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10508     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10509
10510     /* try SubDir2 after CostFinalize */
10511     size = MAX_PATH;
10512     lstrcpyA(path, "kiwi");
10513     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10514     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10515     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10516     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10517
10518     /* nonexistent directory */
10519     size = MAX_PATH;
10520     lstrcpyA(path, "kiwi");
10521     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
10522     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10523     ok(!lstrcmpA(path, "kiwi"),
10524        "Expected path to be unchanged, got \"%s\"\n", path);
10525     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10526
10527     /* NULL szPathBuf */
10528     size = MAX_PATH;
10529     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
10530     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10531     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10532
10533     /* NULL pcchPathBuf */
10534     lstrcpyA(path, "kiwi");
10535     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
10536     ok(r == ERROR_INVALID_PARAMETER,
10537        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10538     ok(!lstrcmpA(path, "kiwi"),
10539        "Expected path to be unchanged, got \"%s\"\n", path);
10540
10541     /* pcchPathBuf is 0 */
10542     size = 0;
10543     lstrcpyA(path, "kiwi");
10544     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10545     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10546     ok(!lstrcmpA(path, "kiwi"),
10547        "Expected path to be unchanged, got \"%s\"\n", path);
10548     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10549
10550     /* pcchPathBuf does not have room for NULL terminator */
10551     size = lstrlenA(cwd);
10552     lstrcpyA(path, "kiwi");
10553     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10554     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
10555     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
10556        "Expected path with no backslash, got \"%s\"\n", path);
10557     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10558
10559     /* pcchPathBuf has room for NULL terminator */
10560     size = lstrlenA(cwd) + 1;
10561     lstrcpyA(path, "kiwi");
10562     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10563     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10564     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10565     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10566
10567     /* remove property */
10568     r = MsiSetProperty(hpkg, "SourceDir", NULL);
10569     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10570
10571     /* try SourceDir again */
10572     size = MAX_PATH;
10573     lstrcpyA(path, "kiwi");
10574     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10576     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10577     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10578
10579     /* set property to a valid directory */
10580     r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
10581     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10582
10583     /* try SOURCEDIR again */
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     MsiCloseHandle(hpkg);
10593
10594     /* compressed source */
10595
10596     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
10597     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10598
10599     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
10600
10601     r = package_from_db(hdb, &hpkg);
10602     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10603
10604     /* try TARGETDIR */
10605     size = MAX_PATH;
10606     lstrcpyA(path, "kiwi");
10607     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10608     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10609     ok(!lstrcmpA(path, "kiwi"),
10610        "Expected path to be unchanged, got \"%s\"\n", path);
10611     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10612
10613     /* try SourceDir */
10614     size = MAX_PATH;
10615     lstrcpyA(path, "kiwi");
10616     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10617     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10618     ok(!lstrcmpA(path, "kiwi"),
10619        "Expected path to be unchanged, got \"%s\"\n", path);
10620     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10621
10622     /* try SOURCEDIR */
10623     size = MAX_PATH;
10624     lstrcpyA(path, "kiwi");
10625     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10626     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10627     ok(!lstrcmpA(path, "kiwi"),
10628        "Expected path to be unchanged, got \"%s\"\n", path);
10629     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10630
10631     /* source path nor the property exist */
10632     size = MAX_PATH;
10633     lstrcpyA(path, "kiwi");
10634     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10635     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10636     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10637     ok(size == 0, "Expected 0, got %d\n", size);
10638
10639     /* try SubDir */
10640     size = MAX_PATH;
10641     lstrcpyA(path, "kiwi");
10642     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10643     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10644     ok(!lstrcmpA(path, "kiwi"),
10645        "Expected path to be unchanged, got \"%s\"\n", path);
10646     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10647
10648     /* try SubDir2 */
10649     size = MAX_PATH;
10650     lstrcpyA(path, "kiwi");
10651     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10652     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10653     ok(!lstrcmpA(path, "kiwi"),
10654        "Expected path to be unchanged, got \"%s\"\n", path);
10655     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10656
10657     r = MsiDoAction(hpkg, "CostInitialize");
10658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10659
10660     /* try TARGETDIR after CostInitialize */
10661     size = MAX_PATH;
10662     lstrcpyA(path, "kiwi");
10663     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10665     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10666     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10667
10668     /* try SourceDir after CostInitialize */
10669     size = MAX_PATH;
10670     lstrcpyA(path, "kiwi");
10671     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10672     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10673     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10674     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10675
10676     /* try SOURCEDIR after CostInitialize */
10677     size = MAX_PATH;
10678     lstrcpyA(path, "kiwi");
10679     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10680     todo_wine
10681     {
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
10687     /* source path does not exist, but the property exists */
10688     size = MAX_PATH;
10689     lstrcpyA(path, "kiwi");
10690     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10691     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10692     todo_wine
10693     {
10694         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10695         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10696     }
10697
10698     /* try SubDir after CostInitialize */
10699     size = MAX_PATH;
10700     lstrcpyA(path, "kiwi");
10701     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10702     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10703     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10704     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10705
10706     /* try SubDir2 after CostInitialize */
10707     size = MAX_PATH;
10708     lstrcpyA(path, "kiwi");
10709     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10711     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10712     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10713
10714     r = MsiDoAction(hpkg, "ResolveSource");
10715     ok(r == ERROR_SUCCESS, "file cost failed\n");
10716
10717     /* try TARGETDIR after ResolveSource */
10718     size = MAX_PATH;
10719     lstrcpyA(path, "kiwi");
10720     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10721     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10722     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10723     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10724
10725     /* try SourceDir after ResolveSource */
10726     size = MAX_PATH;
10727     lstrcpyA(path, "kiwi");
10728     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10729     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10730     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10731     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10732
10733     /* try SOURCEDIR after ResolveSource */
10734     size = MAX_PATH;
10735     lstrcpyA(path, "kiwi");
10736     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10737     todo_wine
10738     {
10739         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10740         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10741         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10742     }
10743
10744     /* source path and the property exist */
10745     size = MAX_PATH;
10746     lstrcpyA(path, "kiwi");
10747     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10749     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10750     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10751
10752     /* try SubDir after ResolveSource */
10753     size = MAX_PATH;
10754     lstrcpyA(path, "kiwi");
10755     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10756     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10757     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10758     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10759
10760     /* try SubDir2 after ResolveSource */
10761     size = MAX_PATH;
10762     lstrcpyA(path, "kiwi");
10763     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10764     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10765     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10766     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10767
10768     r = MsiDoAction(hpkg, "FileCost");
10769     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10770
10771     /* try TARGETDIR after CostFinalize */
10772     size = MAX_PATH;
10773     lstrcpyA(path, "kiwi");
10774     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10775     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10776     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10777     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10778
10779     /* try SourceDir after CostFinalize */
10780     size = MAX_PATH;
10781     lstrcpyA(path, "kiwi");
10782     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10783     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10784     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10785     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10786
10787     /* try SOURCEDIR after CostFinalize */
10788     size = MAX_PATH;
10789     lstrcpyA(path, "kiwi");
10790     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10791     todo_wine
10792     {
10793         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10794         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10795         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10796     }
10797
10798     /* source path and the property exist */
10799     size = MAX_PATH;
10800     lstrcpyA(path, "kiwi");
10801     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10802     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10803     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10804     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10805
10806     /* try SubDir after CostFinalize */
10807     size = MAX_PATH;
10808     lstrcpyA(path, "kiwi");
10809     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10811     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10812     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10813
10814     /* try SubDir2 after CostFinalize */
10815     size = MAX_PATH;
10816     lstrcpyA(path, "kiwi");
10817     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10818     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10819     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10820     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10821
10822     r = MsiDoAction(hpkg, "CostFinalize");
10823     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10824
10825     /* try TARGETDIR after CostFinalize */
10826     size = MAX_PATH;
10827     lstrcpyA(path, "kiwi");
10828     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10829     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10830     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10831     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10832
10833     /* try SourceDir after CostFinalize */
10834     size = MAX_PATH;
10835     lstrcpyA(path, "kiwi");
10836     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10838     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10839     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10840
10841     /* try SOURCEDIR after CostFinalize */
10842     size = MAX_PATH;
10843     lstrcpyA(path, "kiwi");
10844     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10845     todo_wine
10846     {
10847         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10848         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10849         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10850     }
10851
10852     /* source path and the property exist */
10853     size = MAX_PATH;
10854     lstrcpyA(path, "kiwi");
10855     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10856     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10857     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10858     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10859
10860     /* try SubDir after CostFinalize */
10861     size = MAX_PATH;
10862     lstrcpyA(path, "kiwi");
10863     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10865     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10866     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10867
10868     /* try SubDir2 after CostFinalize */
10869     size = MAX_PATH;
10870     lstrcpyA(path, "kiwi");
10871     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10872     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10873     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10874     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10875
10876     MsiCloseHandle(hpkg);
10877     DeleteFile(msifile);
10878 }
10879
10880 static void test_shortlongsource(void)
10881 {
10882     MSIHANDLE hdb, hpkg;
10883     CHAR path[MAX_PATH];
10884     CHAR cwd[MAX_PATH];
10885     CHAR subsrc[MAX_PATH];
10886     DWORD size;
10887     UINT r;
10888
10889     lstrcpyA(cwd, CURR_DIR);
10890     lstrcatA(cwd, "\\");
10891
10892     lstrcpyA(subsrc, cwd);
10893     lstrcatA(subsrc, "long");
10894     lstrcatA(subsrc, "\\");
10895
10896     /* long file names */
10897
10898     hdb = create_package_db();
10899     ok( hdb, "failed to create database\n");
10900
10901     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10902
10903     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10904     ok(r == S_OK, "failed\n");
10905
10906     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
10907     ok(r == S_OK, "failed\n");
10908
10909     /* CostInitialize:short */
10910     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
10911     ok(r == S_OK, "failed\n");
10912
10913     /* CostInitialize:long */
10914     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
10915     ok(r == S_OK, "failed\n");
10916
10917     /* FileCost:short */
10918     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
10919     ok(r == S_OK, "failed\n");
10920
10921     /* FileCost:long */
10922     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
10923     ok(r == S_OK, "failed\n");
10924
10925     /* CostFinalize:short */
10926     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
10927     ok(r == S_OK, "failed\n");
10928
10929     /* CostFinalize:long */
10930     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
10931     ok(r == S_OK, "failed\n");
10932
10933     MsiDatabaseCommit(hdb);
10934
10935     r = package_from_db(hdb, &hpkg);
10936     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10937     {
10938         skip("Not enough rights to perform tests\n");
10939         DeleteFile(msifile);
10940         return;
10941     }
10942     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10943
10944     MsiCloseHandle(hdb);
10945
10946     CreateDirectoryA("one", NULL);
10947     CreateDirectoryA("four", NULL);
10948
10949     r = MsiDoAction(hpkg, "CostInitialize");
10950     ok(r == ERROR_SUCCESS, "file cost failed\n");
10951
10952     CreateDirectory("five", NULL);
10953     CreateDirectory("eight", NULL);
10954
10955     r = MsiDoAction(hpkg, "FileCost");
10956     ok(r == ERROR_SUCCESS, "file cost failed\n");
10957
10958     CreateDirectory("nine", NULL);
10959     CreateDirectory("twelve", NULL);
10960
10961     r = MsiDoAction(hpkg, "CostFinalize");
10962     ok(r == ERROR_SUCCESS, "file cost failed\n");
10963
10964     /* neither short nor long source directories exist */
10965     size = MAX_PATH;
10966     lstrcpyA(path, "kiwi");
10967     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10969     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10970     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10971
10972     CreateDirectoryA("short", NULL);
10973
10974     /* short source directory exists */
10975     size = MAX_PATH;
10976     lstrcpyA(path, "kiwi");
10977     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10978     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10979     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10980     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10981
10982     CreateDirectoryA("long", NULL);
10983
10984     /* both short and long source directories exist */
10985     size = MAX_PATH;
10986     lstrcpyA(path, "kiwi");
10987     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10989     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10990     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10991
10992     lstrcpyA(subsrc, cwd);
10993     lstrcatA(subsrc, "two");
10994     lstrcatA(subsrc, "\\");
10995
10996     /* short dir exists before CostInitialize */
10997     size = MAX_PATH;
10998     lstrcpyA(path, "kiwi");
10999     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11001     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11002     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11003
11004     lstrcpyA(subsrc, cwd);
11005     lstrcatA(subsrc, "four");
11006     lstrcatA(subsrc, "\\");
11007
11008     /* long dir exists before CostInitialize */
11009     size = MAX_PATH;
11010     lstrcpyA(path, "kiwi");
11011     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11013     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11014     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11015
11016     lstrcpyA(subsrc, cwd);
11017     lstrcatA(subsrc, "six");
11018     lstrcatA(subsrc, "\\");
11019
11020     /* short dir exists before FileCost */
11021     size = MAX_PATH;
11022     lstrcpyA(path, "kiwi");
11023     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11025     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11026     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11027
11028     lstrcpyA(subsrc, cwd);
11029     lstrcatA(subsrc, "eight");
11030     lstrcatA(subsrc, "\\");
11031
11032     /* long dir exists before FileCost */
11033     size = MAX_PATH;
11034     lstrcpyA(path, "kiwi");
11035     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11036     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11037     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11038     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11039
11040     lstrcpyA(subsrc, cwd);
11041     lstrcatA(subsrc, "ten");
11042     lstrcatA(subsrc, "\\");
11043
11044     /* short dir exists before CostFinalize */
11045     size = MAX_PATH;
11046     lstrcpyA(path, "kiwi");
11047     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11048     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11049     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11050     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11051
11052     lstrcpyA(subsrc, cwd);
11053     lstrcatA(subsrc, "twelve");
11054     lstrcatA(subsrc, "\\");
11055
11056     /* long dir exists before CostFinalize */
11057     size = MAX_PATH;
11058     lstrcpyA(path, "kiwi");
11059     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11060     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11061     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11062     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11063
11064     MsiCloseHandle(hpkg);
11065     RemoveDirectoryA("short");
11066     RemoveDirectoryA("long");
11067     RemoveDirectoryA("one");
11068     RemoveDirectoryA("four");
11069     RemoveDirectoryA("five");
11070     RemoveDirectoryA("eight");
11071     RemoveDirectoryA("nine");
11072     RemoveDirectoryA("twelve");
11073
11074     /* short file names */
11075
11076     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11078
11079     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
11080
11081     r = package_from_db(hdb, &hpkg);
11082     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11083
11084     MsiCloseHandle(hdb);
11085
11086     CreateDirectoryA("one", NULL);
11087     CreateDirectoryA("four", NULL);
11088
11089     r = MsiDoAction(hpkg, "CostInitialize");
11090     ok(r == ERROR_SUCCESS, "file cost failed\n");
11091
11092     CreateDirectory("five", NULL);
11093     CreateDirectory("eight", NULL);
11094
11095     r = MsiDoAction(hpkg, "FileCost");
11096     ok(r == ERROR_SUCCESS, "file cost failed\n");
11097
11098     CreateDirectory("nine", NULL);
11099     CreateDirectory("twelve", NULL);
11100
11101     r = MsiDoAction(hpkg, "CostFinalize");
11102     ok(r == ERROR_SUCCESS, "file cost failed\n");
11103
11104     lstrcpyA(subsrc, cwd);
11105     lstrcatA(subsrc, "short");
11106     lstrcatA(subsrc, "\\");
11107
11108     /* neither short nor long source directories exist */
11109     size = MAX_PATH;
11110     lstrcpyA(path, "kiwi");
11111     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11112     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11113     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11114     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11115
11116     CreateDirectoryA("short", NULL);
11117
11118     /* short source directory exists */
11119     size = MAX_PATH;
11120     lstrcpyA(path, "kiwi");
11121     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11123     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11124     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11125
11126     CreateDirectoryA("long", NULL);
11127
11128     /* both short and long source directories exist */
11129     size = MAX_PATH;
11130     lstrcpyA(path, "kiwi");
11131     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11132     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11133     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11134     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11135
11136     lstrcpyA(subsrc, cwd);
11137     lstrcatA(subsrc, "one");
11138     lstrcatA(subsrc, "\\");
11139
11140     /* short dir exists before CostInitialize */
11141     size = MAX_PATH;
11142     lstrcpyA(path, "kiwi");
11143     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11144     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11145     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11146     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11147
11148     lstrcpyA(subsrc, cwd);
11149     lstrcatA(subsrc, "three");
11150     lstrcatA(subsrc, "\\");
11151
11152     /* long dir exists before CostInitialize */
11153     size = MAX_PATH;
11154     lstrcpyA(path, "kiwi");
11155     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11156     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11157     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11158     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11159
11160     lstrcpyA(subsrc, cwd);
11161     lstrcatA(subsrc, "five");
11162     lstrcatA(subsrc, "\\");
11163
11164     /* short dir exists before FileCost */
11165     size = MAX_PATH;
11166     lstrcpyA(path, "kiwi");
11167     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11168     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11169     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11170     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11171
11172     lstrcpyA(subsrc, cwd);
11173     lstrcatA(subsrc, "seven");
11174     lstrcatA(subsrc, "\\");
11175
11176     /* long dir exists before FileCost */
11177     size = MAX_PATH;
11178     lstrcpyA(path, "kiwi");
11179     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11180     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11181     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11182     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11183
11184     lstrcpyA(subsrc, cwd);
11185     lstrcatA(subsrc, "nine");
11186     lstrcatA(subsrc, "\\");
11187
11188     /* short dir exists before CostFinalize */
11189     size = MAX_PATH;
11190     lstrcpyA(path, "kiwi");
11191     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11192     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11193     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11194     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11195
11196     lstrcpyA(subsrc, cwd);
11197     lstrcatA(subsrc, "eleven");
11198     lstrcatA(subsrc, "\\");
11199
11200     /* long dir exists before CostFinalize */
11201     size = MAX_PATH;
11202     lstrcpyA(path, "kiwi");
11203     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11204     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11205     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11206     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11207
11208     MsiCloseHandle(hpkg);
11209     RemoveDirectoryA("short");
11210     RemoveDirectoryA("long");
11211     RemoveDirectoryA("one");
11212     RemoveDirectoryA("four");
11213     RemoveDirectoryA("five");
11214     RemoveDirectoryA("eight");
11215     RemoveDirectoryA("nine");
11216     RemoveDirectoryA("twelve");
11217     DeleteFileA(msifile);
11218 }
11219
11220 static void test_sourcedir(void)
11221 {
11222     MSIHANDLE hdb, hpkg;
11223     CHAR package[12];
11224     CHAR path[MAX_PATH];
11225     CHAR cwd[MAX_PATH];
11226     CHAR subsrc[MAX_PATH];
11227     DWORD size;
11228     UINT r;
11229
11230     lstrcpyA(cwd, CURR_DIR);
11231     lstrcatA(cwd, "\\");
11232
11233     lstrcpyA(subsrc, cwd);
11234     lstrcatA(subsrc, "long");
11235     lstrcatA(subsrc, "\\");
11236
11237     hdb = create_package_db();
11238     ok( hdb, "failed to create database\n");
11239
11240     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11241     ok(r == S_OK, "failed\n");
11242
11243     sprintf(package, "#%u", hdb);
11244     r = MsiOpenPackage(package, &hpkg);
11245     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11246     {
11247         skip("Not enough rights to perform tests\n");
11248         goto error;
11249     }
11250     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11251
11252     /* properties only */
11253
11254     /* SourceDir prop */
11255     size = MAX_PATH;
11256     lstrcpyA(path, "kiwi");
11257     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11258     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11259     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11260     ok(size == 0, "Expected 0, got %d\n", size);
11261
11262     /* SOURCEDIR prop */
11263     size = MAX_PATH;
11264     lstrcpyA(path, "kiwi");
11265     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11266     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11267     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11268     ok(size == 0, "Expected 0, got %d\n", size);
11269
11270     r = MsiDoAction(hpkg, "CostInitialize");
11271     ok(r == ERROR_SUCCESS, "file cost failed\n");
11272
11273     /* SourceDir after CostInitialize */
11274     size = MAX_PATH;
11275     lstrcpyA(path, "kiwi");
11276     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11277     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11278     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11279     ok(size == 0, "Expected 0, got %d\n", size);
11280
11281     /* SOURCEDIR after CostInitialize */
11282     size = MAX_PATH;
11283     lstrcpyA(path, "kiwi");
11284     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11285     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11286     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11287     ok(size == 0, "Expected 0, got %d\n", size);
11288
11289     r = MsiDoAction(hpkg, "FileCost");
11290     ok(r == ERROR_SUCCESS, "file cost failed\n");
11291
11292     /* SourceDir after FileCost */
11293     size = MAX_PATH;
11294     lstrcpyA(path, "kiwi");
11295     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11296     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11297     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11298     ok(size == 0, "Expected 0, got %d\n", size);
11299
11300     /* SOURCEDIR after FileCost */
11301     size = MAX_PATH;
11302     lstrcpyA(path, "kiwi");
11303     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11304     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11305     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11306     ok(size == 0, "Expected 0, got %d\n", size);
11307
11308     r = MsiDoAction(hpkg, "CostFinalize");
11309     ok(r == ERROR_SUCCESS, "file cost failed\n");
11310
11311     /* SourceDir after CostFinalize */
11312     size = MAX_PATH;
11313     lstrcpyA(path, "kiwi");
11314     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11315     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11316     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11317     ok(size == 0, "Expected 0, got %d\n", size);
11318
11319     /* SOURCEDIR after CostFinalize */
11320     size = MAX_PATH;
11321     lstrcpyA(path, "kiwi");
11322     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11323     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11324     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11325     ok(size == 0, "Expected 0, got %d\n", size);
11326
11327     r = MsiDoAction(hpkg, "ResolveSource");
11328     ok(r == ERROR_SUCCESS, "file cost failed\n");
11329
11330     /* SourceDir after ResolveSource */
11331     size = MAX_PATH;
11332     lstrcpyA(path, "kiwi");
11333     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11334     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11335     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11336     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11337
11338     /* SOURCEDIR after ResolveSource */
11339     size = MAX_PATH;
11340     lstrcpyA(path, "kiwi");
11341     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11342     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11343     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11344     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11345
11346     /* random casing */
11347     size = MAX_PATH;
11348     lstrcpyA(path, "kiwi");
11349     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
11350     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11351     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11352     ok(size == 0, "Expected 0, got %d\n", size);
11353
11354     MsiCloseHandle(hpkg);
11355
11356     /* reset the package state */
11357     sprintf(package, "#%i", hdb);
11358     r = MsiOpenPackage(package, &hpkg);
11359     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11360
11361     /* test how MsiGetSourcePath affects the properties */
11362
11363     /* SourceDir prop */
11364     size = MAX_PATH;
11365     lstrcpyA(path, "kiwi");
11366     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11367     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11368     todo_wine
11369     {
11370         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11371         ok(size == 0, "Expected 0, got %d\n", size);
11372     }
11373
11374     size = MAX_PATH;
11375     lstrcpyA(path, "kiwi");
11376     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11377     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11378     ok(!lstrcmpA(path, "kiwi"),
11379        "Expected path to be unchanged, got \"%s\"\n", path);
11380     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11381
11382     /* SourceDir after MsiGetSourcePath */
11383     size = MAX_PATH;
11384     lstrcpyA(path, "kiwi");
11385     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11386     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11387     todo_wine
11388     {
11389         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11390         ok(size == 0, "Expected 0, got %d\n", size);
11391     }
11392
11393     /* SOURCEDIR prop */
11394     size = MAX_PATH;
11395     lstrcpyA(path, "kiwi");
11396     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11398     todo_wine
11399     {
11400         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11401         ok(size == 0, "Expected 0, got %d\n", size);
11402     }
11403
11404     size = MAX_PATH;
11405     lstrcpyA(path, "kiwi");
11406     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11407     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11408     ok(!lstrcmpA(path, "kiwi"),
11409        "Expected path to be unchanged, got \"%s\"\n", path);
11410     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11411
11412     /* SOURCEDIR prop after MsiGetSourcePath */
11413     size = MAX_PATH;
11414     lstrcpyA(path, "kiwi");
11415     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11417     todo_wine
11418     {
11419         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11420         ok(size == 0, "Expected 0, got %d\n", size);
11421     }
11422
11423     r = MsiDoAction(hpkg, "CostInitialize");
11424     ok(r == ERROR_SUCCESS, "file cost failed\n");
11425
11426     /* SourceDir after CostInitialize */
11427     size = MAX_PATH;
11428     lstrcpyA(path, "kiwi");
11429     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11431     todo_wine
11432     {
11433         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11434         ok(size == 0, "Expected 0, got %d\n", size);
11435     }
11436
11437     size = MAX_PATH;
11438     lstrcpyA(path, "kiwi");
11439     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11440     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11441     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11442     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11443
11444     /* SourceDir after MsiGetSourcePath */
11445     size = MAX_PATH;
11446     lstrcpyA(path, "kiwi");
11447     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11449     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11450     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11451
11452     /* SOURCEDIR after CostInitialize */
11453     size = MAX_PATH;
11454     lstrcpyA(path, "kiwi");
11455     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11457     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11458     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11459
11460     /* SOURCEDIR source path still does not exist */
11461     size = MAX_PATH;
11462     lstrcpyA(path, "kiwi");
11463     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11464     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11465     ok(!lstrcmpA(path, "kiwi"),
11466        "Expected path to be unchanged, got \"%s\"\n", path);
11467     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11468
11469     r = MsiDoAction(hpkg, "FileCost");
11470     ok(r == ERROR_SUCCESS, "file cost failed\n");
11471
11472     /* SourceDir after FileCost */
11473     size = MAX_PATH;
11474     lstrcpyA(path, "kiwi");
11475     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11476     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11477     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11478     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11479
11480     /* SOURCEDIR after FileCost */
11481     size = MAX_PATH;
11482     lstrcpyA(path, "kiwi");
11483     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11485     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11486     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11487
11488     /* SOURCEDIR source path still does not exist */
11489     size = MAX_PATH;
11490     lstrcpyA(path, "kiwi");
11491     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11492     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11493     ok(!lstrcmpA(path, "kiwi"),
11494        "Expected path to be unchanged, got \"%s\"\n", path);
11495     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11496
11497     r = MsiDoAction(hpkg, "CostFinalize");
11498     ok(r == ERROR_SUCCESS, "file cost failed\n");
11499
11500     /* SourceDir after CostFinalize */
11501     size = MAX_PATH;
11502     lstrcpyA(path, "kiwi");
11503     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11504     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11505     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11506     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11507
11508     /* SOURCEDIR after CostFinalize */
11509     size = MAX_PATH;
11510     lstrcpyA(path, "kiwi");
11511     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11512     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11513     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11514     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11515
11516     /* SOURCEDIR source path still does not exist */
11517     size = MAX_PATH;
11518     lstrcpyA(path, "kiwi");
11519     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11520     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11521     ok(!lstrcmpA(path, "kiwi"),
11522        "Expected path to be unchanged, got \"%s\"\n", path);
11523     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11524
11525     r = MsiDoAction(hpkg, "ResolveSource");
11526     ok(r == ERROR_SUCCESS, "file cost failed\n");
11527
11528     /* SourceDir after ResolveSource */
11529     size = MAX_PATH;
11530     lstrcpyA(path, "kiwi");
11531     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11532     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11533     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11534     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11535
11536     /* SOURCEDIR after ResolveSource */
11537     size = MAX_PATH;
11538     lstrcpyA(path, "kiwi");
11539     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11541     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11542     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11543
11544     /* SOURCEDIR source path still does not exist */
11545     size = MAX_PATH;
11546     lstrcpyA(path, "kiwi");
11547     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11548     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11549     ok(!lstrcmpA(path, "kiwi"),
11550        "Expected path to be unchanged, got \"%s\"\n", path);
11551     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11552
11553     MsiCloseHandle(hpkg);
11554
11555 error:
11556     MsiCloseHandle(hdb);
11557     DeleteFileA(msifile);
11558 }
11559
11560 struct access_res
11561 {
11562     BOOL gothandle;
11563     DWORD lasterr;
11564     BOOL ignore;
11565 };
11566
11567 static const struct access_res create[16] =
11568 {
11569     { TRUE, ERROR_SUCCESS, TRUE },
11570     { TRUE, ERROR_SUCCESS, TRUE },
11571     { TRUE, ERROR_SUCCESS, FALSE },
11572     { TRUE, ERROR_SUCCESS, FALSE },
11573     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11574     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11575     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11576     { TRUE, ERROR_SUCCESS, FALSE },
11577     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11578     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11579     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11580     { TRUE, ERROR_SUCCESS, TRUE },
11581     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11582     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11583     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11584     { TRUE, ERROR_SUCCESS, TRUE }
11585 };
11586
11587 static const struct access_res create_commit[16] =
11588 {
11589     { TRUE, ERROR_SUCCESS, TRUE },
11590     { TRUE, ERROR_SUCCESS, TRUE },
11591     { TRUE, ERROR_SUCCESS, FALSE },
11592     { TRUE, ERROR_SUCCESS, FALSE },
11593     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11594     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11595     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11596     { TRUE, ERROR_SUCCESS, FALSE },
11597     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11598     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11599     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11600     { TRUE, ERROR_SUCCESS, TRUE },
11601     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11602     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11603     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
11604     { TRUE, ERROR_SUCCESS, TRUE }
11605 };
11606
11607 static const struct access_res create_close[16] =
11608 {
11609     { TRUE, ERROR_SUCCESS, FALSE },
11610     { TRUE, ERROR_SUCCESS, FALSE },
11611     { TRUE, ERROR_SUCCESS, FALSE },
11612     { TRUE, ERROR_SUCCESS, FALSE },
11613     { TRUE, ERROR_SUCCESS, FALSE },
11614     { TRUE, ERROR_SUCCESS, FALSE },
11615     { TRUE, ERROR_SUCCESS, FALSE },
11616     { TRUE, ERROR_SUCCESS, FALSE },
11617     { TRUE, ERROR_SUCCESS, FALSE },
11618     { TRUE, ERROR_SUCCESS, FALSE },
11619     { TRUE, ERROR_SUCCESS, FALSE },
11620     { TRUE, ERROR_SUCCESS, FALSE },
11621     { TRUE, ERROR_SUCCESS, FALSE },
11622     { TRUE, ERROR_SUCCESS, FALSE },
11623     { TRUE, ERROR_SUCCESS, FALSE },
11624     { TRUE, ERROR_SUCCESS }
11625 };
11626
11627 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
11628 {
11629     DWORD access = 0, share = 0;
11630     DWORD lasterr;
11631     HANDLE hfile;
11632     int i, j, idx = 0;
11633
11634     for (i = 0; i < 4; i++)
11635     {
11636         if (i == 0) access = 0;
11637         if (i == 1) access = GENERIC_READ;
11638         if (i == 2) access = GENERIC_WRITE;
11639         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
11640
11641         for (j = 0; j < 4; j++)
11642         {
11643             if (ares[idx].ignore)
11644                 continue;
11645
11646             if (j == 0) share = 0;
11647             if (j == 1) share = FILE_SHARE_READ;
11648             if (j == 2) share = FILE_SHARE_WRITE;
11649             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
11650
11651             SetLastError(0xdeadbeef);
11652             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
11653                                 FILE_ATTRIBUTE_NORMAL, 0);
11654             lasterr = GetLastError();
11655
11656             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
11657                "(%d, handle, %d): Expected %d, got %d\n",
11658                line, idx, ares[idx].gothandle,
11659                (hfile != INVALID_HANDLE_VALUE));
11660
11661             ok(lasterr == ares[idx].lasterr ||
11662                lasterr == 0xdeadbeef, /* win9x */
11663                "(%d, lasterr, %d): Expected %d, got %d\n",
11664                line, idx, ares[idx].lasterr, lasterr);
11665
11666             CloseHandle(hfile);
11667             idx++;
11668         }
11669     }
11670 }
11671
11672 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
11673
11674 static void test_access(void)
11675 {
11676     MSIHANDLE hdb;
11677     UINT r;
11678
11679     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
11680     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11681
11682     test_file_access(msifile, create);
11683
11684     r = MsiDatabaseCommit(hdb);
11685     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11686
11687     test_file_access(msifile, create_commit);
11688
11689     MsiCloseHandle(hdb);
11690
11691     test_file_access(msifile, create_close);
11692
11693     DeleteFileA(msifile);
11694
11695     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
11696     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11697
11698     test_file_access(msifile, create);
11699
11700     r = MsiDatabaseCommit(hdb);
11701     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11702
11703     test_file_access(msifile, create_commit);
11704
11705     MsiCloseHandle(hdb);
11706
11707     test_file_access(msifile, create_close);
11708
11709     DeleteFileA(msifile);
11710 }
11711
11712 static void test_emptypackage(void)
11713 {
11714     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
11715     MSIHANDLE hview = 0, hrec = 0;
11716     MSICONDITION condition;
11717     CHAR buffer[MAX_PATH];
11718     DWORD size;
11719     UINT r;
11720
11721     r = MsiOpenPackageA("", &hpkg);
11722     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11723     {
11724         skip("Not enough rights to perform tests\n");
11725         return;
11726     }
11727     todo_wine
11728     {
11729         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11730     }
11731
11732     hdb = MsiGetActiveDatabase(hpkg);
11733     todo_wine
11734     {
11735         ok(hdb != 0, "Expected a valid database handle\n");
11736     }
11737
11738     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
11739     todo_wine
11740     {
11741         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11742     }
11743     r = MsiViewExecute(hview, 0);
11744     todo_wine
11745     {
11746         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11747     }
11748
11749     r = MsiViewFetch(hview, &hrec);
11750     todo_wine
11751     {
11752         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11753     }
11754
11755     buffer[0] = 0;
11756     size = MAX_PATH;
11757     r = MsiRecordGetString(hrec, 1, buffer, &size);
11758     todo_wine
11759     {
11760         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11761         ok(!lstrcmpA(buffer, "_Property"),
11762            "Expected \"_Property\", got \"%s\"\n", buffer);
11763     }
11764
11765     MsiCloseHandle(hrec);
11766
11767     r = MsiViewFetch(hview, &hrec);
11768     todo_wine
11769     {
11770         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11771     }
11772
11773     size = MAX_PATH;
11774     r = MsiRecordGetString(hrec, 1, buffer, &size);
11775     todo_wine
11776     {
11777         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11778         ok(!lstrcmpA(buffer, "#_FolderCache"),
11779            "Expected \"_Property\", got \"%s\"\n", buffer);
11780     }
11781
11782     MsiCloseHandle(hrec);
11783     MsiViewClose(hview);
11784     MsiCloseHandle(hview);
11785
11786     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
11787     todo_wine
11788     {
11789         ok(condition == MSICONDITION_FALSE,
11790            "Expected MSICONDITION_FALSE, got %d\n", condition);
11791     }
11792
11793     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
11794     todo_wine
11795     {
11796         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11797     }
11798     r = MsiViewExecute(hview, 0);
11799     todo_wine
11800     {
11801         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11802     }
11803
11804     /* _Property table is not empty */
11805     r = MsiViewFetch(hview, &hrec);
11806     todo_wine
11807     {
11808         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11809     }
11810
11811     MsiCloseHandle(hrec);
11812     MsiViewClose(hview);
11813     MsiCloseHandle(hview);
11814
11815     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
11816     todo_wine
11817     {
11818         ok(condition == MSICONDITION_FALSE,
11819            "Expected MSICONDITION_FALSE, got %d\n", condition);
11820     }
11821
11822     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
11823     todo_wine
11824     {
11825         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11826     }
11827     r = MsiViewExecute(hview, 0);
11828     todo_wine
11829     {
11830         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11831     }
11832
11833     /* #_FolderCache is not empty */
11834     r = MsiViewFetch(hview, &hrec);
11835     todo_wine
11836     {
11837         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11838     }
11839
11840     MsiCloseHandle(hrec);
11841     MsiViewClose(hview);
11842     MsiCloseHandle(hview);
11843
11844     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
11845     todo_wine
11846     {
11847         ok(r == ERROR_BAD_QUERY_SYNTAX,
11848            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11849     }
11850
11851     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
11852     todo_wine
11853     {
11854         ok(r == ERROR_BAD_QUERY_SYNTAX,
11855            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
11856     }
11857
11858     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
11859     todo_wine
11860     {
11861         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
11862            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
11863     }
11864
11865     MsiCloseHandle(hsuminfo);
11866
11867     r = MsiDatabaseCommit(hdb);
11868     todo_wine
11869     {
11870         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11871     }
11872
11873     MsiCloseHandle(hdb);
11874     MsiCloseHandle(hpkg);
11875 }
11876
11877 static void test_MsiGetProductProperty(void)
11878 {
11879     MSIHANDLE hprod, hdb;
11880     CHAR val[MAX_PATH];
11881     CHAR path[MAX_PATH];
11882     CHAR query[MAX_PATH];
11883     CHAR keypath[MAX_PATH*2];
11884     CHAR prodcode[MAX_PATH];
11885     CHAR prod_squashed[MAX_PATH];
11886     HKEY prodkey, userkey, props;
11887     DWORD size;
11888     LONG res;
11889     UINT r;
11890     SC_HANDLE scm;
11891     REGSAM access = KEY_ALL_ACCESS;
11892     BOOL wow64;
11893
11894     scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
11895     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
11896     {
11897         win_skip("Different registry keys on Win9x and WinMe\n");
11898         return;
11899     }
11900     CloseServiceHandle(scm);
11901
11902     GetCurrentDirectoryA(MAX_PATH, path);
11903     lstrcatA(path, "\\");
11904
11905     create_test_guid(prodcode, prod_squashed);
11906
11907     if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
11908         access |= KEY_WOW64_64KEY;
11909
11910     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
11911     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11912
11913     r = MsiDatabaseCommit(hdb);
11914     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11915
11916     r = set_summary_info(hdb);
11917     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11918
11919     r = run_query(hdb,
11920             "CREATE TABLE `Directory` ( "
11921             "`Directory` CHAR(255) NOT NULL, "
11922             "`Directory_Parent` CHAR(255), "
11923             "`DefaultDir` CHAR(255) NOT NULL "
11924             "PRIMARY KEY `Directory`)");
11925     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11926
11927     r = run_query(hdb,
11928             "CREATE TABLE `Property` ( "
11929             "`Property` CHAR(72) NOT NULL, "
11930             "`Value` CHAR(255) "
11931             "PRIMARY KEY `Property`)");
11932     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11933
11934     sprintf(query, "INSERT INTO `Property` "
11935             "(`Property`, `Value`) "
11936             "VALUES( 'ProductCode', '%s' )", prodcode);
11937     r = run_query(hdb, query);
11938     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11939
11940     r = MsiDatabaseCommit(hdb);
11941     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11942
11943     MsiCloseHandle(hdb);
11944
11945     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
11946     lstrcatA(keypath, prod_squashed);
11947
11948     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
11949     if (res == ERROR_ACCESS_DENIED)
11950     {
11951         skip("Not enough rights to perform tests\n");
11952         DeleteFile(msifile);
11953         return;
11954     }
11955     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11956
11957     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11958     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
11959     lstrcatA(keypath, prod_squashed);
11960
11961     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
11962     if (res == ERROR_ACCESS_DENIED)
11963     {
11964         skip("Not enough rights to perform tests\n");
11965         RegDeleteKeyA(prodkey, "");
11966         RegCloseKey(prodkey);
11967         return;
11968     }
11969     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11970
11971     res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
11972     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11973
11974     lstrcpyA(val, path);
11975     lstrcatA(val, "\\");
11976     lstrcatA(val, msifile);
11977     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
11978                          (const BYTE *)val, lstrlenA(val) + 1);
11979     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11980
11981     hprod = 0xdeadbeef;
11982     r = MsiOpenProductA(prodcode, &hprod);
11983     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11984     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
11985
11986     /* hProduct is invalid */
11987     size = MAX_PATH;
11988     lstrcpyA(val, "apple");
11989     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
11990     ok(r == ERROR_INVALID_HANDLE,
11991        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
11992     ok(!lstrcmpA(val, "apple"),
11993        "Expected val to be unchanged, got \"%s\"\n", val);
11994     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11995
11996     /* szProperty is NULL */
11997     size = MAX_PATH;
11998     lstrcpyA(val, "apple");
11999     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
12000     ok(r == ERROR_INVALID_PARAMETER,
12001        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12002     ok(!lstrcmpA(val, "apple"),
12003        "Expected val to be unchanged, got \"%s\"\n", val);
12004     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12005
12006     /* szProperty is empty */
12007     size = MAX_PATH;
12008     lstrcpyA(val, "apple");
12009     r = MsiGetProductPropertyA(hprod, "", val, &size);
12010     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12011     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12012     ok(size == 0, "Expected 0, got %d\n", size);
12013
12014     /* get the property */
12015     size = MAX_PATH;
12016     lstrcpyA(val, "apple");
12017     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12018     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12019     ok(!lstrcmpA(val, prodcode),
12020        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12021     ok(size == lstrlenA(prodcode),
12022        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12023
12024     /* lpValueBuf is NULL */
12025     size = MAX_PATH;
12026     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
12027     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12028     ok(size == lstrlenA(prodcode),
12029        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12030
12031     /* pcchValueBuf is NULL */
12032     lstrcpyA(val, "apple");
12033     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
12034     ok(r == ERROR_INVALID_PARAMETER,
12035        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12036     ok(!lstrcmpA(val, "apple"),
12037        "Expected val to be unchanged, got \"%s\"\n", val);
12038     ok(size == lstrlenA(prodcode),
12039        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12040
12041     /* pcchValueBuf is too small */
12042     size = 4;
12043     lstrcpyA(val, "apple");
12044     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12045     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12046     ok(!strncmp(val, prodcode, 3),
12047        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
12048     ok(size == lstrlenA(prodcode),
12049        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12050
12051     /* pcchValueBuf does not leave room for NULL terminator */
12052     size = lstrlenA(prodcode);
12053     lstrcpyA(val, "apple");
12054     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12055     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12056     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
12057        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
12058     ok(size == lstrlenA(prodcode),
12059        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12060
12061     /* pcchValueBuf has enough room for NULL terminator */
12062     size = lstrlenA(prodcode) + 1;
12063     lstrcpyA(val, "apple");
12064     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12066     ok(!lstrcmpA(val, prodcode),
12067        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12068     ok(size == lstrlenA(prodcode),
12069        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12070
12071     /* nonexistent property */
12072     size = MAX_PATH;
12073     lstrcpyA(val, "apple");
12074     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
12075     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12076     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12077     ok(size == 0, "Expected 0, got %d\n", size);
12078
12079     r = MsiSetPropertyA(hprod, "NewProperty", "value");
12080     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12081
12082     /* non-product property set */
12083     size = MAX_PATH;
12084     lstrcpyA(val, "apple");
12085     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
12086     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12087     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12088     ok(size == 0, "Expected 0, got %d\n", size);
12089
12090     r = MsiSetPropertyA(hprod, "ProductCode", "value");
12091     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12092
12093     /* non-product property that is also a product property set */
12094     size = MAX_PATH;
12095     lstrcpyA(val, "apple");
12096     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12098     ok(!lstrcmpA(val, prodcode),
12099        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12100     ok(size == lstrlenA(prodcode),
12101        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12102
12103     MsiCloseHandle(hprod);
12104
12105     RegDeleteValueA(props, "LocalPackage");
12106     delete_key(props, "", access);
12107     RegCloseKey(props);
12108     delete_key(userkey, "", access);
12109     RegCloseKey(userkey);
12110     delete_key(prodkey, "", access);
12111     RegCloseKey(prodkey);
12112     DeleteFileA(msifile);
12113 }
12114
12115 static void test_MsiSetProperty(void)
12116 {
12117     MSIHANDLE hpkg, hdb, hrec;
12118     CHAR buf[MAX_PATH];
12119     LPCSTR query;
12120     DWORD size;
12121     UINT r;
12122
12123     r = package_from_db(create_package_db(), &hpkg);
12124     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12125     {
12126         skip("Not enough rights to perform tests\n");
12127         DeleteFile(msifile);
12128         return;
12129     }
12130     ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
12131
12132     /* invalid hInstall */
12133     r = MsiSetPropertyA(0, "Prop", "Val");
12134     ok(r == ERROR_INVALID_HANDLE,
12135        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12136
12137     /* invalid hInstall */
12138     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
12139     ok(r == ERROR_INVALID_HANDLE,
12140        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12141
12142     /* szName is NULL */
12143     r = MsiSetPropertyA(hpkg, NULL, "Val");
12144     ok(r == ERROR_INVALID_PARAMETER,
12145        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12146
12147     /* both szName and szValue are NULL */
12148     r = MsiSetPropertyA(hpkg, NULL, NULL);
12149     ok(r == ERROR_INVALID_PARAMETER,
12150        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12151
12152     /* szName is empty */
12153     r = MsiSetPropertyA(hpkg, "", "Val");
12154     ok(r == ERROR_FUNCTION_FAILED,
12155        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
12156
12157     /* szName is empty and szValue is NULL */
12158     r = MsiSetPropertyA(hpkg, "", NULL);
12159     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12160
12161     /* set a property */
12162     r = MsiSetPropertyA(hpkg, "Prop", "Val");
12163     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12164
12165     /* 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, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
12170     ok(size == 3, "Expected 3, got %d\n", size);
12171
12172     /* update the property */
12173     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
12174     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12175
12176     /* get the property */
12177     size = MAX_PATH;
12178     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12179     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12180     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
12181     ok(size == 4, "Expected 4, got %d\n", size);
12182
12183     hdb = MsiGetActiveDatabase(hpkg);
12184     ok(hdb != 0, "Expected a valid database handle\n");
12185
12186     /* set prop is not in the _Property table */
12187     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
12188     r = do_query(hdb, query, &hrec);
12189     ok(r == ERROR_BAD_QUERY_SYNTAX,
12190        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12191
12192     /* set prop is not in the Property table */
12193     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
12194     r = do_query(hdb, query, &hrec);
12195     ok(r == ERROR_BAD_QUERY_SYNTAX,
12196        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12197
12198     MsiCloseHandle(hdb);
12199
12200     /* szValue is an empty string */
12201     r = MsiSetPropertyA(hpkg, "Prop", "");
12202     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12203
12204     /* try to get the property */
12205     size = MAX_PATH;
12206     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12207     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12208     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12209     ok(size == 0, "Expected 0, got %d\n", size);
12210
12211     /* reset the property */
12212     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
12213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12214
12215     /* delete the property */
12216     r = MsiSetPropertyA(hpkg, "Prop", NULL);
12217     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12218
12219     /* try to get the property */
12220     size = MAX_PATH;
12221     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12222     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12223     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12224     ok(size == 0, "Expected 0, got %d\n", size);
12225
12226     MsiCloseHandle(hpkg);
12227     DeleteFileA(msifile);
12228 }
12229
12230 static void test_MsiApplyMultiplePatches(void)
12231 {
12232     UINT r, type = GetDriveType(NULL);
12233
12234     if (!pMsiApplyMultiplePatchesA) {
12235         win_skip("MsiApplyMultiplePatchesA not found\n");
12236         return;
12237     }
12238
12239     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
12240     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12241
12242     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
12243     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12244
12245     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
12246     todo_wine
12247     {
12248         if (type == DRIVE_FIXED)
12249             ok(r == ERROR_PATH_NOT_FOUND,
12250                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12251         else
12252             ok(r == ERROR_INVALID_NAME,
12253                "Expected ERROR_INVALID_NAME, got %u\n", r);
12254     }
12255
12256     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
12257     todo_wine
12258     {
12259         if (type == DRIVE_FIXED)
12260             ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED,
12261                "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
12262         else
12263             ok(r == ERROR_INVALID_NAME,
12264                "Expected ERROR_INVALID_NAME, got %u\n", r);
12265     }
12266
12267     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
12268     todo_wine
12269     {
12270         if (type == DRIVE_FIXED)
12271             ok(r == ERROR_PATH_NOT_FOUND,
12272                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12273         else
12274             ok(r == ERROR_INVALID_NAME,
12275                "Expected ERROR_INVALID_NAME, got %u\n", r);
12276     }
12277
12278     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
12279     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12280
12281     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
12282     todo_wine
12283     {
12284         if (type == DRIVE_FIXED)
12285             ok(r == ERROR_PATH_NOT_FOUND,
12286                "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12287         else
12288             ok(r == ERROR_INVALID_NAME,
12289                "Expected ERROR_INVALID_NAME, got %u\n", r);
12290     }
12291
12292     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
12293     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12294
12295     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
12296     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12297 }
12298
12299 static void test_MsiApplyPatch(void)
12300 {
12301     UINT r;
12302
12303     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
12304     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12305
12306     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
12307     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12308 }
12309
12310 START_TEST(package)
12311 {
12312     STATEMGRSTATUS status;
12313     BOOL ret = FALSE;
12314
12315     init_functionpointers();
12316
12317     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
12318
12319     /* Create a restore point ourselves so we circumvent the multitude of restore points
12320      * that would have been created by all the installation and removal tests.
12321      */
12322     if (pSRSetRestorePointA)
12323     {
12324         memset(&status, 0, sizeof(status));
12325         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
12326     }
12327
12328     test_createpackage();
12329     test_doaction();
12330     test_gettargetpath_bad();
12331     test_settargetpath();
12332     test_props();
12333     test_property_table();
12334     test_condition();
12335     test_msipackage();
12336     test_formatrecord2();
12337     test_states();
12338     test_getproperty();
12339     test_removefiles();
12340     test_appsearch();
12341     test_appsearch_complocator();
12342     test_appsearch_reglocator();
12343     test_appsearch_inilocator();
12344     test_appsearch_drlocator();
12345     test_featureparents();
12346     test_installprops();
12347     test_launchconditions();
12348     test_ccpsearch();
12349     test_complocator();
12350     test_MsiGetSourcePath();
12351     test_shortlongsource();
12352     test_sourcedir();
12353     test_access();
12354     test_emptypackage();
12355     test_MsiGetProductProperty();
12356     test_MsiSetProperty();
12357     test_MsiApplyMultiplePatches();
12358     test_MsiApplyPatch();
12359
12360     if (pSRSetRestorePointA && ret)
12361     {
12362         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
12363         if (ret)
12364             remove_restore_point(status.llSequenceNumber);
12365     }
12366 }