tools: Register the MSI service from wine.inf.
[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 #include <shlobj.h>
31
32 #include "wine/test.h"
33
34 static BOOL is_wow64;
35 static const char msifile[] = "winetest-package.msi";
36 static char CURR_DIR[MAX_PATH];
37
38 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
39 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
40 static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
41
42 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
43 static BOOL (WINAPI *pGetTokenInformation)( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );
44 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
45 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
46 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
47 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
48 static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
49 static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO);
50 static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR, UINT);
51
52 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
53 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
54
55 static void init_functionpointers(void)
56 {
57     HMODULE hmsi = GetModuleHandleA("msi.dll");
58     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
59     HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
60     HMODULE hshell32 = GetModuleHandleA("shell32.dll");
61     HMODULE hsrclient;
62
63 #define GET_PROC(mod, func) \
64     p ## func = (void*)GetProcAddress(mod, #func);
65
66     GET_PROC(hmsi, MsiApplyMultiplePatchesA);
67     GET_PROC(hmsi, MsiGetComponentPathExA);
68     GET_PROC(hshell32, SHGetFolderPathA);
69
70     GET_PROC(hadvapi32, ConvertSidToStringSidA);
71     GET_PROC(hadvapi32, GetTokenInformation);
72     GET_PROC(hadvapi32, OpenProcessToken);
73     GET_PROC(hadvapi32, RegDeleteKeyExA)
74     GET_PROC(hadvapi32, RegDeleteKeyExW)
75     GET_PROC(hkernel32, IsWow64Process)
76     GET_PROC(hkernel32, GetNativeSystemInfo)
77     GET_PROC(hkernel32, GetSystemInfo)
78     GET_PROC(hkernel32, GetSystemWow64DirectoryA)
79
80     hsrclient = LoadLibraryA("srclient.dll");
81     GET_PROC(hsrclient, SRRemoveRestorePoint);
82     GET_PROC(hsrclient, SRSetRestorePointA);
83 #undef GET_PROC
84 }
85
86 static BOOL is_process_limited(void)
87 {
88     HANDLE token;
89
90     if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
91
92     if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
93     {
94         BOOL ret;
95         TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
96         DWORD size;
97
98         ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
99         CloseHandle(token);
100         return (ret && type == TokenElevationTypeLimited);
101     }
102     return FALSE;
103 }
104
105 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
106 {
107     if (pRegDeleteKeyExA)
108         return pRegDeleteKeyExA( key, subkey, access, 0 );
109     return RegDeleteKeyA( key, subkey );
110 }
111
112 static char *get_user_sid(void)
113 {
114     HANDLE token;
115     DWORD size = 0;
116     TOKEN_USER *user;
117     char *usersid = NULL;
118
119     if (!pConvertSidToStringSidA)
120     {
121         win_skip("ConvertSidToStringSidA is not available\n");
122         return NULL;
123     }
124     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
125     GetTokenInformation(token, TokenUser, NULL, size, &size);
126
127     user = HeapAlloc(GetProcessHeap(), 0, size);
128     GetTokenInformation(token, TokenUser, user, size, &size);
129     pConvertSidToStringSidA(user->User.Sid, &usersid);
130     HeapFree(GetProcessHeap(), 0, user);
131
132     CloseHandle(token);
133     return usersid;
134 }
135
136 /* RegDeleteTreeW from dlls/advapi32/registry.c */
137 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
138 {
139     LONG ret;
140     DWORD dwMaxSubkeyLen, dwMaxValueLen;
141     DWORD dwMaxLen, dwSize;
142     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
143     HKEY hSubKey = hKey;
144
145     if(lpszSubKey)
146     {
147         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
148         if (ret) return ret;
149     }
150
151     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
152             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
153     if (ret) goto cleanup;
154
155     dwMaxSubkeyLen++;
156     dwMaxValueLen++;
157     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
158     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
159     {
160         /* Name too big: alloc a buffer for it */
161         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
162         {
163             ret = ERROR_NOT_ENOUGH_MEMORY;
164             goto cleanup;
165         }
166     }
167
168     /* Recursively delete all the subkeys */
169     while (TRUE)
170     {
171         dwSize = dwMaxLen;
172         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
173                           NULL, NULL, NULL)) break;
174
175         ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
176         if (ret) goto cleanup;
177     }
178
179     if (lpszSubKey)
180     {
181         if (pRegDeleteKeyExW)
182             ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
183         else
184             ret = RegDeleteKeyW(hKey, lpszSubKey);
185     }
186     else
187         while (TRUE)
188         {
189             dwSize = dwMaxLen;
190             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
191                   NULL, NULL, NULL, NULL)) break;
192
193             ret = RegDeleteValueW(hKey, lpszName);
194             if (ret) goto cleanup;
195         }
196
197 cleanup:
198     if (lpszName != szNameBuf)
199         HeapFree(GetProcessHeap(), 0, lpszName);
200     if(lpszSubKey)
201         RegCloseKey(hSubKey);
202     return ret;
203 }
204
205 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
206 {
207     DWORD i,n=1;
208     GUID guid;
209
210     if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
211         return FALSE;
212
213     for(i=0; i<8; i++)
214         out[7-i] = in[n++];
215     n++;
216     for(i=0; i<4; i++)
217         out[11-i] = in[n++];
218     n++;
219     for(i=0; i<4; i++)
220         out[15-i] = in[n++];
221     n++;
222     for(i=0; i<2; i++)
223     {
224         out[17+i*2] = in[n++];
225         out[16+i*2] = in[n++];
226     }
227     n++;
228     for( ; i<8; i++)
229     {
230         out[17+i*2] = in[n++];
231         out[16+i*2] = in[n++];
232     }
233     out[32]=0;
234     return TRUE;
235 }
236
237 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
238 {
239     WCHAR guidW[MAX_PATH];
240     WCHAR squashedW[MAX_PATH];
241     GUID guid;
242     HRESULT hr;
243     int size;
244
245     hr = CoCreateGuid(&guid);
246     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
247
248     size = StringFromGUID2(&guid, guidW, MAX_PATH);
249     ok(size == 39, "Expected 39, got %d\n", hr);
250
251     WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
252     squash_guid(guidW, squashedW);
253     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
254 }
255
256 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
257                                LPCSTR guid, LPSTR usersid, BOOL dir)
258 {
259     WCHAR guidW[MAX_PATH];
260     WCHAR squashedW[MAX_PATH];
261     CHAR squashed[MAX_PATH];
262     CHAR comppath[MAX_PATH];
263     CHAR prodpath[MAX_PATH];
264     CHAR path[MAX_PATH];
265     LPCSTR prod = NULL;
266     HKEY hkey;
267     REGSAM access = KEY_ALL_ACCESS;
268
269     if (is_wow64)
270         access |= KEY_WOW64_64KEY;
271
272     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
273     squash_guid(guidW, squashedW);
274     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
275
276     if (context == MSIINSTALLCONTEXT_MACHINE)
277     {
278         prod = "3D0DAE300FACA1300AD792060BCDAA92";
279         sprintf(comppath,
280                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
281                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
282         lstrcpyA(prodpath,
283                  "SOFTWARE\\Classes\\Installer\\"
284                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
285     }
286     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
287     {
288         prod = "7D2F387510109040002000060BECB6AB";
289         sprintf(comppath,
290                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
291                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
292         sprintf(prodpath,
293                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
294                 "Installer\\%s\\Installer\\Products\\"
295                 "7D2F387510109040002000060BECB6AB", usersid);
296     }
297     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
298     {
299         prod = "7D2F387510109040002000060BECB6AB";
300         sprintf(comppath,
301                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
302                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
303         sprintf(prodpath,
304                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
305                 "Installer\\Managed\\%s\\Installer\\Products\\"
306                 "7D2F387510109040002000060BECB6AB", usersid);
307     }
308
309     RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
310
311     lstrcpyA(path, CURR_DIR);
312     lstrcatA(path, "\\");
313     if (!dir) lstrcatA(path, filename);
314
315     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
316     RegCloseKey(hkey);
317
318     RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
319     RegCloseKey(hkey);
320 }
321
322 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
323 {
324     WCHAR guidW[MAX_PATH];
325     WCHAR squashedW[MAX_PATH];
326     WCHAR substrW[MAX_PATH];
327     CHAR squashed[MAX_PATH];
328     CHAR comppath[MAX_PATH];
329     CHAR prodpath[MAX_PATH];
330     REGSAM access = KEY_ALL_ACCESS;
331
332     if (is_wow64)
333         access |= KEY_WOW64_64KEY;
334
335     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
336     squash_guid(guidW, squashedW);
337     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
338
339     if (context == MSIINSTALLCONTEXT_MACHINE)
340     {
341         sprintf(comppath,
342                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
343                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
344         lstrcpyA(prodpath,
345                  "SOFTWARE\\Classes\\Installer\\"
346                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
347     }
348     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
349     {
350         sprintf(comppath,
351                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
352                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
353         sprintf(prodpath,
354                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
355                 "Installer\\%s\\Installer\\Products\\"
356                 "7D2F387510109040002000060BECB6AB", usersid);
357     }
358     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
359     {
360         sprintf(comppath,
361                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
362                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
363         sprintf(prodpath,
364                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
365                 "Installer\\Managed\\%s\\Installer\\Products\\"
366                 "7D2F387510109040002000060BECB6AB", usersid);
367     }
368
369     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
370     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
371
372     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
373     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
374 }
375
376 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
377 {
378     MSIHANDLE hview = 0;
379     UINT r, ret;
380
381     /* open a select query */
382     r = MsiDatabaseOpenView(hdb, query, &hview);
383     if (r != ERROR_SUCCESS)
384         return r;
385     r = MsiViewExecute(hview, 0);
386     if (r != ERROR_SUCCESS)
387         return r;
388     ret = MsiViewFetch(hview, phrec);
389     r = MsiViewClose(hview);
390     if (r != ERROR_SUCCESS)
391         return r;
392     r = MsiCloseHandle(hview);
393     if (r != ERROR_SUCCESS)
394         return r;
395     return ret;
396 }
397
398 static UINT run_query( MSIHANDLE hdb, const char *query )
399 {
400     MSIHANDLE hview = 0;
401     UINT r;
402
403     r = MsiDatabaseOpenView(hdb, query, &hview);
404     if( r != ERROR_SUCCESS )
405         return r;
406
407     r = MsiViewExecute(hview, 0);
408     if( r == ERROR_SUCCESS )
409         r = MsiViewClose(hview);
410     MsiCloseHandle(hview);
411     return r;
412 }
413
414 static UINT create_component_table( MSIHANDLE hdb )
415 {
416     return run_query( hdb,
417             "CREATE TABLE `Component` ( "
418             "`Component` CHAR(72) NOT NULL, "
419             "`ComponentId` CHAR(38), "
420             "`Directory_` CHAR(72) NOT NULL, "
421             "`Attributes` SHORT NOT NULL, "
422             "`Condition` CHAR(255), "
423             "`KeyPath` CHAR(72) "
424             "PRIMARY KEY `Component`)" );
425 }
426
427 static UINT create_feature_table( MSIHANDLE hdb )
428 {
429     return run_query( hdb,
430             "CREATE TABLE `Feature` ( "
431             "`Feature` CHAR(38) NOT NULL, "
432             "`Feature_Parent` CHAR(38), "
433             "`Title` CHAR(64), "
434             "`Description` CHAR(255), "
435             "`Display` SHORT NOT NULL, "
436             "`Level` SHORT NOT NULL, "
437             "`Directory_` CHAR(72), "
438             "`Attributes` SHORT NOT NULL "
439             "PRIMARY KEY `Feature`)" );
440 }
441
442 static UINT create_feature_components_table( MSIHANDLE hdb )
443 {
444     return run_query( hdb,
445             "CREATE TABLE `FeatureComponents` ( "
446             "`Feature_` CHAR(38) NOT NULL, "
447             "`Component_` CHAR(72) NOT NULL "
448             "PRIMARY KEY `Feature_`, `Component_` )" );
449 }
450
451 static UINT create_file_table( MSIHANDLE hdb )
452 {
453     return run_query( hdb,
454             "CREATE TABLE `File` ("
455             "`File` CHAR(72) NOT NULL, "
456             "`Component_` CHAR(72) NOT NULL, "
457             "`FileName` CHAR(255) NOT NULL, "
458             "`FileSize` LONG NOT NULL, "
459             "`Version` CHAR(72), "
460             "`Language` CHAR(20), "
461             "`Attributes` SHORT, "
462             "`Sequence` SHORT NOT NULL "
463             "PRIMARY KEY `File`)" );
464 }
465
466 static UINT create_remove_file_table( MSIHANDLE hdb )
467 {
468     return run_query( hdb,
469             "CREATE TABLE `RemoveFile` ("
470             "`FileKey` CHAR(72) NOT NULL, "
471             "`Component_` CHAR(72) NOT NULL, "
472             "`FileName` CHAR(255) LOCALIZABLE, "
473             "`DirProperty` CHAR(72) NOT NULL, "
474             "`InstallMode` SHORT NOT NULL "
475             "PRIMARY KEY `FileKey`)" );
476 }
477
478 static UINT create_appsearch_table( MSIHANDLE hdb )
479 {
480     return run_query( hdb,
481             "CREATE TABLE `AppSearch` ("
482             "`Property` CHAR(72) NOT NULL, "
483             "`Signature_` CHAR(72) NOT NULL "
484             "PRIMARY KEY `Property`, `Signature_`)" );
485 }
486
487 static UINT create_reglocator_table( MSIHANDLE hdb )
488 {
489     return run_query( hdb,
490             "CREATE TABLE `RegLocator` ("
491             "`Signature_` CHAR(72) NOT NULL, "
492             "`Root` SHORT NOT NULL, "
493             "`Key` CHAR(255) NOT NULL, "
494             "`Name` CHAR(255), "
495             "`Type` SHORT "
496             "PRIMARY KEY `Signature_`)" );
497 }
498
499 static UINT create_signature_table( MSIHANDLE hdb )
500 {
501     return run_query( hdb,
502             "CREATE TABLE `Signature` ("
503             "`Signature` CHAR(72) NOT NULL, "
504             "`FileName` CHAR(255) NOT NULL, "
505             "`MinVersion` CHAR(20), "
506             "`MaxVersion` CHAR(20), "
507             "`MinSize` LONG, "
508             "`MaxSize` LONG, "
509             "`MinDate` LONG, "
510             "`MaxDate` LONG, "
511             "`Languages` CHAR(255) "
512             "PRIMARY KEY `Signature`)" );
513 }
514
515 static UINT create_launchcondition_table( MSIHANDLE hdb )
516 {
517     return run_query( hdb,
518             "CREATE TABLE `LaunchCondition` ("
519             "`Condition` CHAR(255) NOT NULL, "
520             "`Description` CHAR(255) NOT NULL "
521             "PRIMARY KEY `Condition`)" );
522 }
523
524 static UINT create_property_table( MSIHANDLE hdb )
525 {
526     return run_query( hdb,
527             "CREATE TABLE `Property` ("
528             "`Property` CHAR(72) NOT NULL, "
529             "`Value` CHAR(0) "
530             "PRIMARY KEY `Property`)" );
531 }
532
533 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
534 {
535     return run_query( hdb,
536             "CREATE TABLE `InstallExecuteSequence` ("
537             "`Action` CHAR(72) NOT NULL, "
538             "`Condition` CHAR(255), "
539             "`Sequence` SHORT "
540             "PRIMARY KEY `Action`)" );
541 }
542
543 static UINT create_media_table( MSIHANDLE hdb )
544 {
545     return run_query( hdb,
546             "CREATE TABLE `Media` ("
547             "`DiskId` SHORT NOT NULL, "
548             "`LastSequence` SHORT NOT NULL, "
549             "`DiskPrompt` CHAR(64), "
550             "`Cabinet` CHAR(255), "
551             "`VolumeLabel` CHAR(32), "
552             "`Source` CHAR(72) "
553             "PRIMARY KEY `DiskId`)" );
554 }
555
556 static UINT create_ccpsearch_table( MSIHANDLE hdb )
557 {
558     return run_query( hdb,
559             "CREATE TABLE `CCPSearch` ("
560             "`Signature_` CHAR(72) NOT NULL "
561             "PRIMARY KEY `Signature_`)" );
562 }
563
564 static UINT create_drlocator_table( MSIHANDLE hdb )
565 {
566     return run_query( hdb,
567             "CREATE TABLE `DrLocator` ("
568             "`Signature_` CHAR(72) NOT NULL, "
569             "`Parent` CHAR(72), "
570             "`Path` CHAR(255), "
571             "`Depth` SHORT "
572             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
573 }
574
575 static UINT create_complocator_table( MSIHANDLE hdb )
576 {
577     return run_query( hdb,
578             "CREATE TABLE `CompLocator` ("
579             "`Signature_` CHAR(72) NOT NULL, "
580             "`ComponentId` CHAR(38) NOT NULL, "
581             "`Type` SHORT "
582             "PRIMARY KEY `Signature_`)" );
583 }
584
585 static UINT create_inilocator_table( MSIHANDLE hdb )
586 {
587     return run_query( hdb,
588             "CREATE TABLE `IniLocator` ("
589             "`Signature_` CHAR(72) NOT NULL, "
590             "`FileName` CHAR(255) NOT NULL, "
591             "`Section` CHAR(96)NOT NULL, "
592             "`Key` CHAR(128)NOT NULL, "
593             "`Field` SHORT, "
594             "`Type` SHORT "
595             "PRIMARY KEY `Signature_`)" );
596 }
597
598 #define make_add_entry(type, qtext) \
599     static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
600     { \
601         char insert[] = qtext; \
602         char *query; \
603         UINT sz, r; \
604         sz = strlen(values) + sizeof insert; \
605         query = HeapAlloc(GetProcessHeap(),0,sz); \
606         sprintf(query,insert,values); \
607         r = run_query( hdb, query ); \
608         HeapFree(GetProcessHeap(), 0, query); \
609         return r; \
610     }
611
612 make_add_entry(component,
613                "INSERT INTO `Component`  "
614                "(`Component`, `ComponentId`, `Directory_`, "
615                "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
616
617 make_add_entry(directory,
618                "INSERT INTO `Directory` "
619                "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
620
621 make_add_entry(feature,
622                "INSERT INTO `Feature` "
623                "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
624                "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
625
626 make_add_entry(feature_components,
627                "INSERT INTO `FeatureComponents` "
628                "(`Feature_`, `Component_`) VALUES( %s )")
629
630 make_add_entry(file,
631                "INSERT INTO `File` "
632                "(`File`, `Component_`, `FileName`, `FileSize`, "
633                "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
634
635 make_add_entry(appsearch,
636                "INSERT INTO `AppSearch` "
637                "(`Property`, `Signature_`) VALUES( %s )")
638
639 make_add_entry(signature,
640                "INSERT INTO `Signature` "
641                "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
642                " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
643                "VALUES( %s )")
644
645 make_add_entry(launchcondition,
646                "INSERT INTO `LaunchCondition` "
647                "(`Condition`, `Description`) VALUES( %s )")
648
649 make_add_entry(property,
650                "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
651
652 make_add_entry(install_execute_sequence,
653                "INSERT INTO `InstallExecuteSequence` "
654                "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
655
656 make_add_entry(media,
657                "INSERT INTO `Media` "
658                "(`DiskId`, `LastSequence`, `DiskPrompt`, "
659                "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
660
661 make_add_entry(ccpsearch,
662                "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
663
664 make_add_entry(drlocator,
665                "INSERT INTO `DrLocator` "
666                "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
667
668 make_add_entry(complocator,
669                "INSERT INTO `CompLocator` "
670                "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
671
672 make_add_entry(inilocator,
673                "INSERT INTO `IniLocator` "
674                "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
675                "VALUES( %s )")
676
677 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
678                                   const char *name, UINT type )
679 {
680     const char insert[] =
681         "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
682         "VALUES( '%s', %u, '%s', '%s', %u )";
683     char *query;
684     UINT sz, r;
685
686     sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
687     query = HeapAlloc( GetProcessHeap(), 0, sz );
688     sprintf( query, insert, sig, root, path, name, type );
689     r = run_query( hdb, query );
690     HeapFree( GetProcessHeap(), 0, query );
691     return r;
692 }
693
694 static UINT set_summary_info(MSIHANDLE hdb)
695 {
696     UINT res;
697     MSIHANDLE suminfo;
698
699     /* build summary info */
700     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
701     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
702
703     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
704                         "Installation Database");
705     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
706
707     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
708                         "Installation Database");
709     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
710
711     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
712                         "Wine Hackers");
713     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
714
715     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
716                     ";1033");
717     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
718
719     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
720                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
721     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
722
723     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
724     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
725
726     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
727     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
728
729     res = MsiSummaryInfoPersist(suminfo);
730     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
731
732     res = MsiCloseHandle( suminfo);
733     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
734
735     return res;
736 }
737
738
739 static MSIHANDLE create_package_db(void)
740 {
741     MSIHANDLE hdb = 0;
742     UINT res;
743
744     DeleteFile(msifile);
745
746     /* create an empty database */
747     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
748     ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
749     if( res != ERROR_SUCCESS )
750         return hdb;
751
752     res = MsiDatabaseCommit( hdb );
753     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
754
755     res = set_summary_info(hdb);
756     ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", res);
757
758     res = run_query( hdb,
759             "CREATE TABLE `Directory` ( "
760             "`Directory` CHAR(255) NOT NULL, "
761             "`Directory_Parent` CHAR(255), "
762             "`DefaultDir` CHAR(255) NOT NULL "
763             "PRIMARY KEY `Directory`)" );
764     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
765
766     return hdb;
767 }
768
769 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
770 {
771     UINT res;
772     CHAR szPackage[12];
773     MSIHANDLE hPackage;
774
775     sprintf(szPackage, "#%u", hdb);
776     res = MsiOpenPackage(szPackage, &hPackage);
777     if (res != ERROR_SUCCESS)
778     {
779         MsiCloseHandle(hdb);
780         return res;
781     }
782
783     res = MsiCloseHandle(hdb);
784     if (res != ERROR_SUCCESS)
785     {
786         MsiCloseHandle(hPackage);
787         return res;
788     }
789
790     *handle = hPackage;
791     return ERROR_SUCCESS;
792 }
793
794 static void create_test_file(const CHAR *name)
795 {
796     HANDLE file;
797     DWORD written;
798
799     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
800     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
801     WriteFile(file, name, strlen(name), &written, NULL);
802     WriteFile(file, "\n", strlen("\n"), &written, NULL);
803     CloseHandle(file);
804 }
805
806 typedef struct _tagVS_VERSIONINFO
807 {
808     WORD wLength;
809     WORD wValueLength;
810     WORD wType;
811     WCHAR szKey[1];
812     WORD wPadding1[1];
813     VS_FIXEDFILEINFO Value;
814     WORD wPadding2[1];
815     WORD wChildren[1];
816 } VS_VERSIONINFO;
817
818 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
819 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
820
821 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
822 {
823     VS_VERSIONINFO *pVerInfo;
824     VS_FIXEDFILEINFO *pFixedInfo;
825     LPBYTE buffer, ofs;
826     CHAR path[MAX_PATH];
827     DWORD handle, size;
828     HANDLE resource;
829     BOOL ret = FALSE;
830
831     GetSystemDirectory(path, MAX_PATH);
832     /* Some dlls can't be updated on Vista/W2K8 */
833     lstrcatA(path, "\\version.dll");
834
835     CopyFileA(path, name, FALSE);
836
837     size = GetFileVersionInfoSize(path, &handle);
838     buffer = HeapAlloc(GetProcessHeap(), 0, size);
839
840     GetFileVersionInfoA(path, 0, size, buffer);
841
842     pVerInfo = (VS_VERSIONINFO *)buffer;
843     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
844     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
845
846     pFixedInfo->dwFileVersionMS = ms;
847     pFixedInfo->dwFileVersionLS = ls;
848     pFixedInfo->dwProductVersionMS = ms;
849     pFixedInfo->dwProductVersionLS = ls;
850
851     resource = BeginUpdateResource(name, FALSE);
852     if (!resource)
853         goto done;
854
855     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
856                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
857         goto done;
858
859     if (!EndUpdateResource(resource, FALSE))
860         goto done;
861
862     ret = TRUE;
863
864 done:
865     HeapFree(GetProcessHeap(), 0, buffer);
866     return ret;
867 }
868
869 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
870 {
871     RESTOREPOINTINFOA spec;
872
873     spec.dwEventType = event_type;
874     spec.dwRestorePtType = APPLICATION_INSTALL;
875     spec.llSequenceNumber = status->llSequenceNumber;
876     lstrcpyA(spec.szDescription, "msitest restore point");
877
878     return pSRSetRestorePointA(&spec, status);
879 }
880
881 static void remove_restore_point(DWORD seq_number)
882 {
883     DWORD res;
884
885     res = pSRRemoveRestorePoint(seq_number);
886     if (res != ERROR_SUCCESS)
887         trace("Failed to remove the restore point : %08x\n", res);
888 }
889
890 static void test_createpackage(void)
891 {
892     MSIHANDLE hPackage = 0;
893     UINT res;
894
895     res = package_from_db(create_package_db(), &hPackage);
896     if (res == ERROR_INSTALL_PACKAGE_REJECTED)
897     {
898         skip("Not enough rights to perform tests\n");
899         DeleteFile(msifile);
900         return;
901     }
902     ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
903
904     res = MsiCloseHandle( hPackage);
905     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
906     DeleteFile(msifile);
907 }
908
909 static void test_doaction( void )
910 {
911     MSIHANDLE hpkg;
912     UINT r;
913
914     r = MsiDoAction( -1, NULL );
915     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
916
917     r = package_from_db(create_package_db(), &hpkg);
918     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
919     {
920         skip("Not enough rights to perform tests\n");
921         DeleteFile(msifile);
922         return;
923     }
924     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
925
926     r = MsiDoAction(hpkg, NULL);
927     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
928
929     r = MsiDoAction(0, "boo");
930     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
931
932     r = MsiDoAction(hpkg, "boo");
933     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
934
935     MsiCloseHandle( hpkg );
936     DeleteFile(msifile);
937 }
938
939 static void test_gettargetpath_bad(void)
940 {
941     static const WCHAR boo[] = {'b','o','o',0};
942     static const WCHAR empty[] = {0};
943     char buffer[0x80];
944     WCHAR bufferW[0x80];
945     MSIHANDLE hpkg;
946     DWORD sz;
947     UINT r;
948
949     r = package_from_db(create_package_db(), &hpkg);
950     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
951     {
952         skip("Not enough rights to perform tests\n");
953         DeleteFile(msifile);
954         return;
955     }
956     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
957
958     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
959     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
960
961     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
962     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
963
964     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
965     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
966
967     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
968     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
969
970     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
971     ok( r == ERROR_DIRECTORY, "wrong return val\n");
972
973     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
974     ok( r == ERROR_DIRECTORY, "wrong return val\n");
975
976     sz = 0;
977     r = MsiGetTargetPath( hpkg, "", buffer, &sz );
978     ok( r == ERROR_DIRECTORY, "wrong return val\n");
979
980     r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
981     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
982
983     r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
984     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
985
986     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
987     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
988
989     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
990     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
991
992     r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
993     ok( r == ERROR_DIRECTORY, "wrong return val\n");
994
995     r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
996     ok( r == ERROR_DIRECTORY, "wrong return val\n");
997
998     sz = 0;
999     r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
1000     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1001
1002     MsiCloseHandle( hpkg );
1003     DeleteFile(msifile);
1004 }
1005
1006 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1007 {
1008     UINT r;
1009     DWORD size;
1010     MSIHANDLE rec;
1011
1012     rec = MsiCreateRecord( 1 );
1013     ok(rec, "MsiCreate record failed\n");
1014
1015     r = MsiRecordSetString( rec, 0, file );
1016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1017
1018     size = MAX_PATH;
1019     r = MsiFormatRecord( hpkg, rec, buff, &size );
1020     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1021
1022     MsiCloseHandle( rec );
1023 }
1024
1025 static void test_settargetpath(void)
1026 {
1027     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1028     DWORD sz;
1029     MSIHANDLE hpkg;
1030     UINT r;
1031     MSIHANDLE hdb;
1032
1033     hdb = create_package_db();
1034     ok ( hdb, "failed to create package database\n" );
1035
1036     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1037     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1038
1039     r = create_component_table( hdb );
1040     ok( r == S_OK, "cannot create Component table: %d\n", r );
1041
1042     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1043     ok( r == S_OK, "cannot add dummy component: %d\n", r );
1044
1045     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1046     ok( r == S_OK, "cannot add test component: %d\n", r );
1047
1048     r = create_feature_table( hdb );
1049     ok( r == S_OK, "cannot create Feature table: %d\n", r );
1050
1051     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1052     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1053
1054     r = create_feature_components_table( hdb );
1055     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1056
1057     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1058     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1059
1060     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1061     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1062
1063     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1064     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1065
1066     r = create_file_table( hdb );
1067     ok( r == S_OK, "cannot create File table: %d\n", r );
1068
1069     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1070     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1071
1072     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1073     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1074
1075     r = package_from_db( hdb, &hpkg );
1076     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1077     {
1078         skip("Not enough rights to perform tests\n");
1079         DeleteFile(msifile);
1080         return;
1081     }
1082     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1083
1084     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1085
1086     r = MsiDoAction( hpkg, "CostInitialize");
1087     ok( r == ERROR_SUCCESS, "cost init failed\n");
1088
1089     r = MsiDoAction( hpkg, "FileCost");
1090     ok( r == ERROR_SUCCESS, "file cost failed\n");
1091
1092     r = MsiDoAction( hpkg, "CostFinalize");
1093     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1094
1095     r = MsiSetTargetPath( 0, NULL, NULL );
1096     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1097
1098     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1099     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1100
1101     r = MsiSetTargetPath( hpkg, "boo", NULL );
1102     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1103
1104     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1105     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1106
1107     sz = sizeof tempdir - 1;
1108     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1109     sprintf( file, "%srootfile.txt", tempdir );
1110     buffer[0] = 0;
1111     query_file_path( hpkg, "[#RootFile]", buffer );
1112     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1113     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1114
1115     GetTempFileName( tempdir, "_wt", 0, buffer );
1116     sprintf( tempdir, "%s\\subdir", buffer );
1117
1118     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1119     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1120         "MsiSetTargetPath on file returned %d\n", r );
1121
1122     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1123     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1124         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1125
1126     DeleteFile( buffer );
1127
1128     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1129     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1130
1131     r = GetFileAttributes( buffer );
1132     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1133
1134     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1135     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1136
1137     sz = sizeof buffer - 1;
1138     lstrcat( tempdir, "\\" );
1139     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1140     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1141     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1142
1143     sprintf( file, "%srootfile.txt", tempdir );
1144     query_file_path( hpkg, "[#RootFile]", buffer );
1145     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1146
1147     sz = sizeof(buffer);
1148     r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1149     ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1150     lstrcatA( tempdir, "TestParent\\" );
1151     ok( !lstrcmpi(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1152
1153     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1154     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1155
1156     sz = sizeof(buffer);
1157     r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1158     ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1159     ok( lstrcmpi(buffer, "C:\\one\\two\\TestDir\\"),
1160         "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1161
1162     query_file_path( hpkg, "[#TestFile]", buffer );
1163     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1164         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1165
1166     sz = sizeof buffer - 1;
1167     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1168     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1169     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1170
1171     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1172     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1173
1174     sz = sizeof buffer - 1;
1175     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1176     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1177     ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1178
1179     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\one\\\\two  " );
1180     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1181
1182     sz = sizeof buffer - 1;
1183     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1184     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1185     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1186
1187     MsiCloseHandle( hpkg );
1188 }
1189
1190 static void test_condition(void)
1191 {
1192     static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1193     static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1194     static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1195     static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1196     MSICONDITION r;
1197     MSIHANDLE hpkg;
1198
1199     r = package_from_db(create_package_db(), &hpkg);
1200     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1201     {
1202         skip("Not enough rights to perform tests\n");
1203         DeleteFile(msifile);
1204         return;
1205     }
1206     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1207
1208     r = MsiEvaluateCondition(0, NULL);
1209     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1210
1211     r = MsiEvaluateCondition(hpkg, NULL);
1212     ok( r == MSICONDITION_NONE, "wrong return val\n");
1213
1214     r = MsiEvaluateCondition(hpkg, "");
1215     ok( r == MSICONDITION_NONE, "wrong return val\n");
1216
1217     r = MsiEvaluateCondition(hpkg, "1");
1218     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1219
1220     r = MsiEvaluateCondition(hpkg, "0");
1221     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1222
1223     r = MsiEvaluateCondition(hpkg, "-1");
1224     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1225
1226     r = MsiEvaluateCondition(hpkg, "0 = 0");
1227     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1228
1229     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1230     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1231
1232     r = MsiEvaluateCondition(hpkg, "0 = 1");
1233     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1234
1235     r = MsiEvaluateCondition(hpkg, "0 > 1");
1236     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1237
1238     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1239     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1240
1241     r = MsiEvaluateCondition(hpkg, "1 > 1");
1242     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1243
1244     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1245     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1246
1247     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1248     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1249
1250     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1251     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1252
1253     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1254     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1255
1256     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1257     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258
1259     r = MsiEvaluateCondition(hpkg, "0 < 1");
1260     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1263     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, "1 < 1");
1266     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1269     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1272     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1275     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1278     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1281     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, "0 >=");
1284     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, " ");
1287     ok( r == MSICONDITION_NONE, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1290     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1293     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1296     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, "not 0");
1299     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, "not LicView");
1302     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1305     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1308     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1311     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1314     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1317     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1318
1319     r = MsiEvaluateCondition(hpkg, "\"0\"");
1320     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1321
1322     r = MsiEvaluateCondition(hpkg, "1 and 2");
1323     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1324
1325     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1326     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1327
1328     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1329     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330
1331     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1332     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333
1334     r = MsiEvaluateCondition(hpkg, "(0)");
1335     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1336
1337     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1338     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1339
1340     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1341     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1342
1343     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1344     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1345
1346     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1347     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1348
1349     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1350     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1351
1352     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1353     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1354
1355     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1356     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1357
1358     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1359     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1360
1361     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1362     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1363
1364     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1365     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1366
1367     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1368     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1369
1370     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1371     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1372
1373     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1374     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1375
1376     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1377     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1378
1379     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1380     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1381
1382     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1383     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1384
1385     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1386     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1387
1388     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1389     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1390
1391     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1392     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1393
1394     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1395     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1396
1397     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1398     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1399
1400     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1401     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1402
1403     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1404     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1405
1406     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1407     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1408
1409     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1410     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1411
1412     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1413     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1414
1415     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1416     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1417
1418     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1419     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1420
1421     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1422     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1423
1424     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1425     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1426
1427     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1428     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1429
1430     MsiSetProperty(hpkg, "mm", "5" );
1431
1432     r = MsiEvaluateCondition(hpkg, "mm = 5");
1433     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1434
1435     r = MsiEvaluateCondition(hpkg, "mm < 6");
1436     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1437
1438     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1439     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1440
1441     r = MsiEvaluateCondition(hpkg, "mm > 4");
1442     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444     r = MsiEvaluateCondition(hpkg, "mm < 12");
1445     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1446
1447     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1448     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1449
1450     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1451     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1452
1453     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1454     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1455
1456     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1457     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1458
1459     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1460     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1461
1462     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1463     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1464
1465     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1466     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1467
1468     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1469     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1470
1471     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1472     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1473
1474     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1475     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1476
1477     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1478     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1479
1480     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1481     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1482
1483     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1484     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1485
1486     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1487     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488
1489     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1490     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1491
1492     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1493     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1494
1495     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1496     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1497
1498     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1499     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1500
1501     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1502     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1503
1504     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1505     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1506
1507     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1508     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1509
1510     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1511     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1512
1513     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1514     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1515
1516     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1517     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1518
1519     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1520     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1521
1522     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1523     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1524
1525     MsiSetProperty(hpkg, "bandalmael", "0" );
1526     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1527     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1528
1529     MsiSetProperty(hpkg, "bandalmael", "" );
1530     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1531     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1532
1533     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1534     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1535     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1536
1537     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1538     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1539     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1540
1541     MsiSetProperty(hpkg, "bandalmael", "0 " );
1542     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1543     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1544
1545     MsiSetProperty(hpkg, "bandalmael", "-0" );
1546     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1547     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1548
1549     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1550     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1551     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1552
1553     MsiSetProperty(hpkg, "bandalmael", "--0" );
1554     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1555     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1556
1557     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1558     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1559     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1560
1561     MsiSetProperty(hpkg, "bandalmael", "-" );
1562     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1563     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1564
1565     MsiSetProperty(hpkg, "bandalmael", "+0" );
1566     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1567     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1568
1569     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1570     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1571     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1572     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1573     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1574
1575     MsiSetProperty(hpkg, "one", "hi");
1576     MsiSetProperty(hpkg, "two", "hithere");
1577     r = MsiEvaluateCondition(hpkg, "one >< two");
1578     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1579
1580     MsiSetProperty(hpkg, "one", "hithere");
1581     MsiSetProperty(hpkg, "two", "hi");
1582     r = MsiEvaluateCondition(hpkg, "one >< two");
1583     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1584
1585     MsiSetProperty(hpkg, "one", "hello");
1586     MsiSetProperty(hpkg, "two", "hi");
1587     r = MsiEvaluateCondition(hpkg, "one >< two");
1588     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1589
1590     MsiSetProperty(hpkg, "one", "hellohithere");
1591     MsiSetProperty(hpkg, "two", "hi");
1592     r = MsiEvaluateCondition(hpkg, "one >< two");
1593     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1594
1595     MsiSetProperty(hpkg, "one", "");
1596     MsiSetProperty(hpkg, "two", "hi");
1597     r = MsiEvaluateCondition(hpkg, "one >< two");
1598     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1599
1600     MsiSetProperty(hpkg, "one", "hi");
1601     MsiSetProperty(hpkg, "two", "");
1602     r = MsiEvaluateCondition(hpkg, "one >< two");
1603     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1604
1605     MsiSetProperty(hpkg, "one", "");
1606     MsiSetProperty(hpkg, "two", "");
1607     r = MsiEvaluateCondition(hpkg, "one >< two");
1608     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1609
1610     MsiSetProperty(hpkg, "one", "1234");
1611     MsiSetProperty(hpkg, "two", "1");
1612     r = MsiEvaluateCondition(hpkg, "one >< two");
1613     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1614
1615     MsiSetProperty(hpkg, "one", "one 1234");
1616     MsiSetProperty(hpkg, "two", "1");
1617     r = MsiEvaluateCondition(hpkg, "one >< two");
1618     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1619
1620     MsiSetProperty(hpkg, "one", "hithere");
1621     MsiSetProperty(hpkg, "two", "hi");
1622     r = MsiEvaluateCondition(hpkg, "one << two");
1623     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1624
1625     MsiSetProperty(hpkg, "one", "hi");
1626     MsiSetProperty(hpkg, "two", "hithere");
1627     r = MsiEvaluateCondition(hpkg, "one << two");
1628     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1629
1630     MsiSetProperty(hpkg, "one", "hi");
1631     MsiSetProperty(hpkg, "two", "hi");
1632     r = MsiEvaluateCondition(hpkg, "one << two");
1633     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1634
1635     MsiSetProperty(hpkg, "one", "abcdhithere");
1636     MsiSetProperty(hpkg, "two", "hi");
1637     r = MsiEvaluateCondition(hpkg, "one << two");
1638     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1639
1640     MsiSetProperty(hpkg, "one", "");
1641     MsiSetProperty(hpkg, "two", "hi");
1642     r = MsiEvaluateCondition(hpkg, "one << two");
1643     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1644
1645     MsiSetProperty(hpkg, "one", "hithere");
1646     MsiSetProperty(hpkg, "two", "");
1647     r = MsiEvaluateCondition(hpkg, "one << two");
1648     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1649
1650     MsiSetProperty(hpkg, "one", "");
1651     MsiSetProperty(hpkg, "two", "");
1652     r = MsiEvaluateCondition(hpkg, "one << two");
1653     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1654
1655     MsiSetProperty(hpkg, "one", "1234");
1656     MsiSetProperty(hpkg, "two", "1");
1657     r = MsiEvaluateCondition(hpkg, "one << two");
1658     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1659
1660     MsiSetProperty(hpkg, "one", "1234 one");
1661     MsiSetProperty(hpkg, "two", "1");
1662     r = MsiEvaluateCondition(hpkg, "one << two");
1663     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1664
1665     MsiSetProperty(hpkg, "one", "hithere");
1666     MsiSetProperty(hpkg, "two", "there");
1667     r = MsiEvaluateCondition(hpkg, "one >> two");
1668     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1669
1670     MsiSetProperty(hpkg, "one", "hithere");
1671     MsiSetProperty(hpkg, "two", "hi");
1672     r = MsiEvaluateCondition(hpkg, "one >> two");
1673     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1674
1675     MsiSetProperty(hpkg, "one", "there");
1676     MsiSetProperty(hpkg, "two", "hithere");
1677     r = MsiEvaluateCondition(hpkg, "one >> two");
1678     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1679
1680     MsiSetProperty(hpkg, "one", "there");
1681     MsiSetProperty(hpkg, "two", "there");
1682     r = MsiEvaluateCondition(hpkg, "one >> two");
1683     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1684
1685     MsiSetProperty(hpkg, "one", "abcdhithere");
1686     MsiSetProperty(hpkg, "two", "hi");
1687     r = MsiEvaluateCondition(hpkg, "one >> two");
1688     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1689
1690     MsiSetProperty(hpkg, "one", "");
1691     MsiSetProperty(hpkg, "two", "there");
1692     r = MsiEvaluateCondition(hpkg, "one >> two");
1693     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1694
1695     MsiSetProperty(hpkg, "one", "there");
1696     MsiSetProperty(hpkg, "two", "");
1697     r = MsiEvaluateCondition(hpkg, "one >> two");
1698     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1699
1700     MsiSetProperty(hpkg, "one", "");
1701     MsiSetProperty(hpkg, "two", "");
1702     r = MsiEvaluateCondition(hpkg, "one >> two");
1703     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1704
1705     MsiSetProperty(hpkg, "one", "1234");
1706     MsiSetProperty(hpkg, "two", "4");
1707     r = MsiEvaluateCondition(hpkg, "one >> two");
1708     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1709
1710     MsiSetProperty(hpkg, "one", "one 1234");
1711     MsiSetProperty(hpkg, "two", "4");
1712     r = MsiEvaluateCondition(hpkg, "one >> two");
1713     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1714
1715     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1716
1717     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1718     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1719
1720     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1721     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1722
1723     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1724     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1725
1726     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1727     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1728
1729     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1730     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1731
1732     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1733     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1734
1735     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1736     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1737
1738     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1739     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1740
1741     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1742     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1743
1744     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1745     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1746
1747     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1748     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749
1750     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1751     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1752
1753     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1754     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1755
1756     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1757     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1758
1759     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1760     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1761
1762     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1763     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1764
1765     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1766     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1767
1768     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1769     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1770
1771     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1772     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1773
1774     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1775     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1776
1777     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
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 < \"!\"");
1784     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1785
1786     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1787     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1788
1789     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1790     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1791
1792     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1793     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1794
1795     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1796     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1797
1798     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1799     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1800
1801     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1802     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1803
1804     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1805     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1806
1807     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1808     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1809
1810     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1811     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1812
1813     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1814     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1815
1816     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1817     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1818
1819     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1820     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1821
1822     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1823     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1824
1825     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1826     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1827
1828     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1829     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1830     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1831
1832     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1833     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1834
1835     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1836     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1837
1838     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1839     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1840
1841     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1842     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1843
1844     MsiSetProperty(hpkg, "one", "1");
1845     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1846     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1847
1848     MsiSetProperty(hpkg, "X", "5.0");
1849
1850     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1851     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1852
1853     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1854     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1855
1856     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1857     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1858
1859     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1860     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1861
1862     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1863     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1864
1865     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1866     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1867
1868     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1869     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1870
1871     /* feature doesn't exist */
1872     r = MsiEvaluateCondition(hpkg, "&nofeature");
1873     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1874
1875     MsiSetProperty(hpkg, "A", "2");
1876     MsiSetProperty(hpkg, "X", "50");
1877
1878     r = MsiEvaluateCondition(hpkg, "2 <= X");
1879     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1880
1881     r = MsiEvaluateCondition(hpkg, "A <= X");
1882     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1883
1884     r = MsiEvaluateCondition(hpkg, "A <= 50");
1885     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1886
1887     MsiSetProperty(hpkg, "X", "50val");
1888
1889     r = MsiEvaluateCondition(hpkg, "2 <= X");
1890     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1891
1892     r = MsiEvaluateCondition(hpkg, "A <= X");
1893     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1894
1895     MsiSetProperty(hpkg, "A", "7");
1896     MsiSetProperty(hpkg, "X", "50");
1897
1898     r = MsiEvaluateCondition(hpkg, "7 <= X");
1899     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1900
1901     r = MsiEvaluateCondition(hpkg, "A <= X");
1902     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1903
1904     r = MsiEvaluateCondition(hpkg, "A <= 50");
1905     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1906
1907     MsiSetProperty(hpkg, "X", "50val");
1908
1909     r = MsiEvaluateCondition(hpkg, "2 <= X");
1910     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1911
1912     r = MsiEvaluateCondition(hpkg, "A <= X");
1913     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1914
1915     r = MsiEvaluateConditionW(hpkg, cond1);
1916     ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1917         "wrong return val (%d)\n", r);
1918
1919     r = MsiEvaluateConditionW(hpkg, cond2);
1920     ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1921         "wrong return val (%d)\n", r);
1922
1923     r = MsiEvaluateConditionW(hpkg, cond3);
1924     ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1925         "wrong return val (%d)\n", r);
1926
1927     r = MsiEvaluateConditionW(hpkg, cond4);
1928     ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1929         "wrong return val (%d)\n", r);
1930
1931     MsiCloseHandle( hpkg );
1932     DeleteFile(msifile);
1933 }
1934
1935 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1936 {
1937     UINT r;
1938     DWORD sz;
1939     char buffer[2];
1940
1941     sz = sizeof buffer;
1942     strcpy(buffer,"x");
1943     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1944     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1945 }
1946
1947 static void test_props(void)
1948 {
1949     MSIHANDLE hpkg, hdb;
1950     UINT r;
1951     DWORD sz;
1952     char buffer[0x100];
1953
1954     hdb = create_package_db();
1955     r = run_query( hdb,
1956             "CREATE TABLE `Property` ( "
1957             "`Property` CHAR(255) NOT NULL, "
1958             "`Value` CHAR(255) "
1959             "PRIMARY KEY `Property`)" );
1960     ok( r == ERROR_SUCCESS , "Failed\n" );
1961
1962     r = run_query(hdb,
1963             "INSERT INTO `Property` "
1964             "(`Property`, `Value`) "
1965             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1966     ok( r == ERROR_SUCCESS , "Failed\n" );
1967
1968     r = package_from_db( hdb, &hpkg );
1969     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1970     {
1971         skip("Not enough rights to perform tests\n");
1972         DeleteFile(msifile);
1973         return;
1974     }
1975     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1976
1977     /* test invalid values */
1978     r = MsiGetProperty( 0, NULL, NULL, NULL );
1979     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1980
1981     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1982     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1983
1984     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1985     ok( r == ERROR_SUCCESS, "wrong return val\n");
1986
1987     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1988     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1989
1990     /* test retrieving an empty/nonexistent property */
1991     sz = sizeof buffer;
1992     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1993     ok( r == ERROR_SUCCESS, "wrong return val\n");
1994     ok( sz == 0, "wrong size returned\n");
1995
1996     check_prop_empty( hpkg, "boo");
1997     sz = 0;
1998     strcpy(buffer,"x");
1999     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2000     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2001     ok( !strcmp(buffer,"x"), "buffer was changed\n");
2002     ok( sz == 0, "wrong size returned\n");
2003
2004     sz = 1;
2005     strcpy(buffer,"x");
2006     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2007     ok( r == ERROR_SUCCESS, "wrong return val\n");
2008     ok( buffer[0] == 0, "buffer was not changed\n");
2009     ok( sz == 0, "wrong size returned\n");
2010
2011     /* set the property to something */
2012     r = MsiSetProperty( 0, NULL, NULL );
2013     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
2014
2015     r = MsiSetProperty( hpkg, NULL, NULL );
2016     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2017
2018     r = MsiSetProperty( hpkg, "", NULL );
2019     ok( r == ERROR_SUCCESS, "wrong return val\n");
2020
2021     /* try set and get some illegal property identifiers */
2022     r = MsiSetProperty( hpkg, "", "asdf" );
2023     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2024
2025     r = MsiSetProperty( hpkg, "=", "asdf" );
2026     ok( r == ERROR_SUCCESS, "wrong return val\n");
2027
2028     r = MsiSetProperty( hpkg, " ", "asdf" );
2029     ok( r == ERROR_SUCCESS, "wrong return val\n");
2030
2031     r = MsiSetProperty( hpkg, "'", "asdf" );
2032     ok( r == ERROR_SUCCESS, "wrong return val\n");
2033
2034     sz = sizeof buffer;
2035     buffer[0]=0;
2036     r = MsiGetProperty( hpkg, "'", buffer, &sz );
2037     ok( r == ERROR_SUCCESS, "wrong return val\n");
2038     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2039
2040     /* set empty values */
2041     r = MsiSetProperty( hpkg, "boo", NULL );
2042     ok( r == ERROR_SUCCESS, "wrong return val\n");
2043     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2044
2045     r = MsiSetProperty( hpkg, "boo", "" );
2046     ok( r == ERROR_SUCCESS, "wrong return val\n");
2047     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2048
2049     /* set a non-empty value */
2050     r = MsiSetProperty( hpkg, "boo", "xyz" );
2051     ok( r == ERROR_SUCCESS, "wrong return val\n");
2052
2053     sz = 1;
2054     strcpy(buffer,"x");
2055     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2056     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2057     ok( buffer[0] == 0, "buffer was not changed\n");
2058     ok( sz == 3, "wrong size returned\n");
2059
2060     sz = 4;
2061     strcpy(buffer,"x");
2062     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2063     ok( r == ERROR_SUCCESS, "wrong return val\n");
2064     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2065     ok( sz == 3, "wrong size returned\n");
2066
2067     sz = 3;
2068     strcpy(buffer,"x");
2069     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2070     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2071     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2072     ok( sz == 3, "wrong size returned\n");
2073
2074     r = MsiSetProperty(hpkg, "SourceDir", "foo");
2075     ok( r == ERROR_SUCCESS, "wrong return val\n");
2076
2077     sz = 4;
2078     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2079     ok( r == ERROR_SUCCESS, "wrong return val\n");
2080     ok( !strcmp(buffer,""), "buffer wrong\n");
2081     ok( sz == 0, "wrong size returned\n");
2082
2083     sz = 4;
2084     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2085     ok( r == ERROR_SUCCESS, "wrong return val\n");
2086     ok( !strcmp(buffer,""), "buffer wrong\n");
2087     ok( sz == 0, "wrong size returned\n");
2088
2089     sz = 4;
2090     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2091     ok( r == ERROR_SUCCESS, "wrong return val\n");
2092     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2093     ok( sz == 3, "wrong size returned\n");
2094
2095     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2096     ok( r == ERROR_SUCCESS, "wrong return val\n");
2097
2098     sz = 0;
2099     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2100     ok( r == ERROR_SUCCESS, "return wrong\n");
2101     ok( sz == 13, "size wrong (%d)\n", sz);
2102
2103     sz = 13;
2104     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2105     ok( r == ERROR_MORE_DATA, "return wrong\n");
2106     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2107
2108     r = MsiSetProperty(hpkg, "property", "value");
2109     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2110
2111     sz = 6;
2112     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2114     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2115
2116     r = MsiSetProperty(hpkg, "property", NULL);
2117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2118
2119     sz = 6;
2120     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2122     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2123
2124     MsiCloseHandle( hpkg );
2125     DeleteFile(msifile);
2126 }
2127
2128 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2129 {
2130     MSIHANDLE hview, hrec;
2131     BOOL found;
2132     CHAR buffer[MAX_PATH];
2133     DWORD sz;
2134     UINT r;
2135
2136     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2137     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2138     r = MsiViewExecute(hview, 0);
2139     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2140
2141     found = FALSE;
2142     while (r == ERROR_SUCCESS && !found)
2143     {
2144         r = MsiViewFetch(hview, &hrec);
2145         if (r != ERROR_SUCCESS) break;
2146
2147         sz = MAX_PATH;
2148         r = MsiRecordGetString(hrec, 1, buffer, &sz);
2149         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2150         {
2151             sz = MAX_PATH;
2152             r = MsiRecordGetString(hrec, 2, buffer, &sz);
2153             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2154                 found = TRUE;
2155         }
2156
2157         MsiCloseHandle(hrec);
2158     }
2159
2160     MsiViewClose(hview);
2161     MsiCloseHandle(hview);
2162
2163     return found;
2164 }
2165
2166 static void test_property_table(void)
2167 {
2168     const char *query;
2169     UINT r;
2170     MSIHANDLE hpkg, hdb, hrec;
2171     char buffer[MAX_PATH], package[10];
2172     DWORD sz;
2173     BOOL found;
2174
2175     hdb = create_package_db();
2176     ok( hdb, "failed to create package\n");
2177
2178     r = package_from_db(hdb, &hpkg);
2179     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2180     {
2181         skip("Not enough rights to perform tests\n");
2182         DeleteFile(msifile);
2183         return;
2184     }
2185     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2186
2187     MsiCloseHandle(hdb);
2188
2189     hdb = MsiGetActiveDatabase(hpkg);
2190
2191     query = "CREATE TABLE `_Property` ( "
2192         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2193     r = run_query(hdb, query);
2194     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2195
2196     MsiCloseHandle(hdb);
2197     MsiCloseHandle(hpkg);
2198     DeleteFile(msifile);
2199
2200     hdb = create_package_db();
2201     ok( hdb, "failed to create package\n");
2202
2203     query = "CREATE TABLE `_Property` ( "
2204         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2205     r = run_query(hdb, query);
2206     ok(r == ERROR_SUCCESS, "failed to create table\n");
2207
2208     query = "ALTER `_Property` ADD `foo` INTEGER";
2209     r = run_query(hdb, query);
2210     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2211
2212     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2213     r = run_query(hdb, query);
2214     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2215
2216     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2217     r = run_query(hdb, query);
2218     ok(r == ERROR_SUCCESS, "failed to add column\n");
2219
2220     sprintf(package, "#%i", hdb);
2221     r = MsiOpenPackage(package, &hpkg);
2222     todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2223     if (r == ERROR_SUCCESS)
2224         MsiCloseHandle(hpkg);
2225
2226     r = MsiCloseHandle(hdb);
2227     ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2228
2229     hdb = create_package_db();
2230     ok (hdb, "failed to create package database\n");
2231
2232     r = create_property_table(hdb);
2233     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2234
2235     r = add_property_entry(hdb, "'prop', 'val'");
2236     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2237
2238     r = package_from_db(hdb, &hpkg);
2239     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2240
2241     MsiCloseHandle(hdb);
2242
2243     sz = MAX_PATH;
2244     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2245     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2246     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2247
2248     hdb = MsiGetActiveDatabase(hpkg);
2249
2250     found = find_prop_in_property(hdb, "prop", "val");
2251     ok(found, "prop should be in the _Property table\n");
2252
2253     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2254     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2255
2256     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2257     r = do_query(hdb, query, &hrec);
2258     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2259
2260     found = find_prop_in_property(hdb, "dantes", "mercedes");
2261     ok(found == FALSE, "dantes should not be in the _Property table\n");
2262
2263     sz = MAX_PATH;
2264     lstrcpy(buffer, "aaa");
2265     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2266     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2267     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2268
2269     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2270     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2271
2272     found = find_prop_in_property(hdb, "dantes", "mercedes");
2273     ok(found == TRUE, "dantes should be in the _Property table\n");
2274
2275     MsiCloseHandle(hdb);
2276     MsiCloseHandle(hpkg);
2277     DeleteFile(msifile);
2278 }
2279
2280 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2281 {
2282     MSIHANDLE htab = 0;
2283     UINT res;
2284
2285     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2286     if( res == ERROR_SUCCESS )
2287     {
2288         UINT r;
2289
2290         r = MsiViewExecute( htab, hrec );
2291         if( r != ERROR_SUCCESS )
2292         {
2293             res = r;
2294             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2295         }
2296
2297         r = MsiViewClose( htab );
2298         if( r != ERROR_SUCCESS )
2299             res = r;
2300
2301         r = MsiCloseHandle( htab );
2302         if( r != ERROR_SUCCESS )
2303             res = r;
2304     }
2305     return res;
2306 }
2307
2308 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2309 {
2310     return try_query_param( hdb, szQuery, 0 );
2311 }
2312
2313 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2314 {
2315     MSIHANDLE summary;
2316     UINT r;
2317
2318     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2319     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2320
2321     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2322     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2323
2324     r = MsiSummaryInfoPersist(summary);
2325     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2326
2327     MsiCloseHandle(summary);
2328 }
2329
2330 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2331 {
2332     MSIHANDLE summary;
2333     UINT r;
2334
2335     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2336     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2337
2338     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2339     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2340
2341     r = MsiSummaryInfoPersist(summary);
2342     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2343
2344     MsiCloseHandle(summary);
2345 }
2346
2347 static void test_msipackage(void)
2348 {
2349     MSIHANDLE hdb = 0, hpack = 100;
2350     UINT r;
2351     const char *query;
2352     char name[10];
2353
2354     /* NULL szPackagePath */
2355     r = MsiOpenPackage(NULL, &hpack);
2356     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2357
2358     /* empty szPackagePath */
2359     r = MsiOpenPackage("", &hpack);
2360     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2361     {
2362         skip("Not enough rights to perform tests\n");
2363         return;
2364     }
2365     todo_wine
2366     {
2367         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2368     }
2369
2370     if (r == ERROR_SUCCESS)
2371         MsiCloseHandle(hpack);
2372
2373     /* nonexistent szPackagePath */
2374     r = MsiOpenPackage("nonexistent", &hpack);
2375     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2376
2377     /* NULL hProduct */
2378     r = MsiOpenPackage(msifile, NULL);
2379     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2380
2381     name[0]='#';
2382     name[1]=0;
2383     r = MsiOpenPackage(name, &hpack);
2384     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2385
2386     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2387     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2388
2389     /* database exists, but is emtpy */
2390     sprintf(name, "#%d", hdb);
2391     r = MsiOpenPackage(name, &hpack);
2392     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2393        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2394
2395     query = "CREATE TABLE `Property` ( "
2396             "`Property` CHAR(72), `Value` CHAR(0) "
2397             "PRIMARY KEY `Property`)";
2398     r = try_query(hdb, query);
2399     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2400
2401     query = "CREATE TABLE `InstallExecuteSequence` ("
2402             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2403             "PRIMARY KEY `Action`)";
2404     r = try_query(hdb, query);
2405     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2406
2407     /* a few key tables exist */
2408     sprintf(name, "#%d", hdb);
2409     r = MsiOpenPackage(name, &hpack);
2410     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2411        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2412
2413     MsiCloseHandle(hdb);
2414     DeleteFile(msifile);
2415
2416     /* start with a clean database to show what constitutes a valid package */
2417     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2419
2420     sprintf(name, "#%d", hdb);
2421
2422     /* The following summary information props must exist:
2423      *  - PID_REVNUMBER
2424      *  - PID_PAGECOUNT
2425      */
2426
2427     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2428     r = MsiOpenPackage(name, &hpack);
2429     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2430        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2431
2432     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2433     r = MsiOpenPackage(name, &hpack);
2434     ok(r == ERROR_SUCCESS,
2435        "Expected ERROR_SUCCESS, got %d\n", r);
2436
2437     MsiCloseHandle(hpack);
2438     MsiCloseHandle(hdb);
2439     DeleteFile(msifile);
2440 }
2441
2442 static void test_formatrecord2(void)
2443 {
2444     MSIHANDLE hpkg, hrec ;
2445     char buffer[0x100];
2446     DWORD sz;
2447     UINT r;
2448
2449     r = package_from_db(create_package_db(), &hpkg);
2450     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2451     {
2452         skip("Not enough rights to perform tests\n");
2453         DeleteFile(msifile);
2454         return;
2455     }
2456     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2457
2458     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2459     ok( r == ERROR_SUCCESS, "set property failed\n");
2460
2461     hrec = MsiCreateRecord(2);
2462     ok(hrec, "create record failed\n");
2463
2464     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2465     ok( r == ERROR_SUCCESS, "format record failed\n");
2466
2467     buffer[0] = 0;
2468     sz = sizeof buffer;
2469     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2471
2472     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2473     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2474     r = MsiRecordSetString(hrec, 1, "hoo");
2475     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2476     sz = sizeof buffer;
2477     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2478     ok( sz == 3, "size wrong\n");
2479     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2480     ok( r == ERROR_SUCCESS, "format failed\n");
2481
2482     r = MsiRecordSetString(hrec, 0, "x[~]x");
2483     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2484     sz = sizeof buffer;
2485     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2486     ok( sz == 3, "size wrong\n");
2487     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2488     ok( r == ERROR_SUCCESS, "format failed\n");
2489
2490     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2492     r = MsiRecordSetString(hrec, 1, "hoo");
2493     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2494     sz = sizeof buffer;
2495     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2496     ok( sz == 3, "size wrong\n");
2497     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2498     ok( r == ERROR_SUCCESS, "format failed\n");
2499
2500     r = MsiRecordSetString(hrec, 0, "[\\[]");
2501     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2502     sz = sizeof buffer;
2503     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2504     ok( sz == 1, "size wrong\n");
2505     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2506     ok( r == ERROR_SUCCESS, "format failed\n");
2507
2508     SetEnvironmentVariable("FOO", "BAR");
2509     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2510     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2511     sz = sizeof buffer;
2512     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2513     ok( sz == 3, "size wrong\n");
2514     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2515     ok( r == ERROR_SUCCESS, "format failed\n");
2516
2517     r = MsiRecordSetString(hrec, 0, "[[1]]");
2518     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2519     r = MsiRecordSetString(hrec, 1, "%FOO");
2520     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
2521     sz = sizeof buffer;
2522     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2523     ok( sz == 3, "size wrong\n");
2524     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2525     ok( r == ERROR_SUCCESS, "format failed\n");
2526
2527     MsiCloseHandle( hrec );
2528     MsiCloseHandle( hpkg );
2529     DeleteFile(msifile);
2530 }
2531
2532 static void test_states(void)
2533 {
2534     MSIHANDLE hpkg;
2535     UINT r;
2536     MSIHANDLE hdb;
2537     INSTALLSTATE state, action;
2538
2539     static const CHAR msifile2[] = "winetest2-package.msi";
2540     static const CHAR msifile3[] = "winetest3-package.msi";
2541     static const CHAR msifile4[] = "winetest4-package.msi";
2542
2543     if (is_process_limited())
2544     {
2545         skip("process is limited\n");
2546         return;
2547     }
2548
2549     hdb = create_package_db();
2550     ok ( hdb, "failed to create package database\n" );
2551
2552     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2553     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2554
2555     r = create_property_table( hdb );
2556     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2557
2558     r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2559     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2560
2561     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2562     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2563
2564     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2565     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2566
2567     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2568     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2569
2570     r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2571     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2572
2573     r = create_install_execute_sequence_table( hdb );
2574     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2575
2576     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2577     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2578
2579     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2580     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2581
2582     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2583     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2584
2585     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2586     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2587
2588     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2589     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2590
2591     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2592     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2593
2594     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2595     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2596
2597     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2598     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2599
2600     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2601     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2602
2603     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2604     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2605
2606     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2607     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2608
2609     r = create_media_table( hdb );
2610     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2611
2612     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2613     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2614
2615     r = create_feature_table( hdb );
2616     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2617
2618     r = create_component_table( hdb );
2619     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2620
2621     /* msidbFeatureAttributesFavorLocal */
2622     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2623     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2624
2625     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2626     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2627     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2628
2629     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2630     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2631     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2632
2633     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2634     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2635     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2636
2637     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2638     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2639     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2640
2641     /* msidbFeatureAttributesFavorSource */
2642     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2643     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2644
2645     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2646     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2647     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2648
2649     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2650     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2651     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2652
2653     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2654     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2655     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2656
2657     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2658     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2659     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2660
2661     /* msidbFeatureAttributesFavorSource */
2662     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2663     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2664
2665     /* msidbFeatureAttributesFavorLocal */
2666     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2667     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2668
2669     /* disabled */
2670     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2671     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2672
2673     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2674     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2675     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2676
2677     /* no feature parent:msidbComponentAttributesLocalOnly */
2678     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2679     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2680
2681     /* msidbFeatureAttributesFavorLocal:removed */
2682     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2683     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2684
2685     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2686     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2687     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2688
2689     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2690     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2691     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2692
2693     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2694     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2695     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2696
2697     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2698     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2699     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2700
2701     /* msidbFeatureAttributesFavorSource:removed */
2702     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2703     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2704
2705     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2706     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2707     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2708
2709     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2710     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2711     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2712
2713     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2714     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2715     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2716
2717     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2718     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2719     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2720
2721     /* msidbFeatureAttributesFavorLocal */
2722     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2723     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2724
2725     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2726     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2727
2728     /* msidbFeatureAttributesFavorSource */
2729     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2730     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2731
2732     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2733     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2734
2735     /* msidbFeatureAttributesFavorAdvertise */
2736     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2737     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2738
2739     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2740     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2741
2742     /* msidbFeatureAttributesUIDisallowAbsent */
2743     r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2744     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2745
2746     r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2747     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2748
2749     r = create_feature_components_table( hdb );
2750     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2751
2752     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2753     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2754
2755     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2756     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2757
2758     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2759     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2760
2761     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2762     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2763
2764     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2765     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2766
2767     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2768     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2769
2770     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2771     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2772
2773     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2774     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2775
2776     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2777     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2778
2779     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2780     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2781
2782     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2783     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2784
2785     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2786     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2787
2788     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2789     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2790
2791     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2792     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2793
2794     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2795     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2796
2797     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2798     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2799
2800     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2801     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2802
2803     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2804     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2805
2806     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2807     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2808
2809     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2810     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2811
2812     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2813     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2814
2815     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2816     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2817
2818     r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2819     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2820
2821     r = create_file_table( hdb );
2822     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2823
2824     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2825     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2826
2827     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2828     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2829
2830     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2831     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2832
2833     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2834     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2835
2836     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2837     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2838
2839     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2840     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2841
2842     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2843     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2844
2845     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2846     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2847
2848     /* compressed file */
2849     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2850     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2851
2852     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2853     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2854
2855     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2856     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2857
2858     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2859     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2860
2861     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2862     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2863
2864     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2865     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2866
2867     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2868     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2869
2870     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2871     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2872
2873     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2874     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2875
2876     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2877     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2878
2879     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2880     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2881
2882     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2883     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2884
2885     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2886     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2887
2888     r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
2889     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2890
2891     MsiDatabaseCommit(hdb);
2892
2893     /* these properties must not be in the saved msi file */
2894     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2895     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2896
2897     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2898     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2899
2900     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2901     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2902
2903     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2904     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2905
2906     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2907     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2908
2909     r = package_from_db( hdb, &hpkg );
2910     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2911     {
2912         skip("Not enough rights to perform tests\n");
2913         DeleteFile(msifile);
2914         return;
2915     }
2916     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2917
2918     MsiCloseHandle(hdb);
2919
2920     CopyFileA(msifile, msifile2, FALSE);
2921     CopyFileA(msifile, msifile3, FALSE);
2922     CopyFileA(msifile, msifile4, FALSE);
2923
2924     state = 0xdeadbee;
2925     action = 0xdeadbee;
2926     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2927     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2928     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2929     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2930
2931     state = 0xdeadbee;
2932     action = 0xdeadbee;
2933     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2934     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2935     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2936     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2937
2938     state = 0xdeadbee;
2939     action = 0xdeadbee;
2940     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2941     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2942     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2943     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2944
2945     state = 0xdeadbee;
2946     action = 0xdeadbee;
2947     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2948     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2949     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2950     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2951
2952     state = 0xdeadbee;
2953     action = 0xdeadbee;
2954     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2955     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2956     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2957     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2958
2959     state = 0xdeadbee;
2960     action = 0xdeadbee;
2961     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2962     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2963     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2964     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2965
2966     state = 0xdeadbee;
2967     action = 0xdeadbee;
2968     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2969     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2970     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2971     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2972
2973     state = 0xdeadbee;
2974     action = 0xdeadbee;
2975     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2976     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2977     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2978     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2979
2980     state = 0xdeadbee;
2981     action = 0xdeadbee;
2982     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2983     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2984     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2985     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2986
2987     state = 0xdeadbee;
2988     action = 0xdeadbee;
2989     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2990     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2991     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2992     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2993
2994     state = 0xdeadbee;
2995     action = 0xdeadbee;
2996     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
2997     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2998     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2999     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3000
3001     state = 0xdeadbee;
3002     action = 0xdeadbee;
3003     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3004     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3005     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3006     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3007
3008     state = 0xdeadbee;
3009     action = 0xdeadbee;
3010     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3011     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3012     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3013     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3014
3015     state = 0xdeadbee;
3016     action = 0xdeadbee;
3017     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3018     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3019     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3020     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3021
3022     state = 0xdeadbee;
3023     action = 0xdeadbee;
3024     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3025     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3026     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3027     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3028
3029     state = 0xdeadbee;
3030     action = 0xdeadbee;
3031     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3032     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3033     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3034     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3035
3036     state = 0xdeadbee;
3037     action = 0xdeadbee;
3038     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3039     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3040     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3041     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3042
3043     state = 0xdeadbee;
3044     action = 0xdeadbee;
3045     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3046     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3047     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3048     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3049
3050     state = 0xdeadbee;
3051     action = 0xdeadbee;
3052     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3053     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3054     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3055     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3056
3057     state = 0xdeadbee;
3058     action = 0xdeadbee;
3059     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3060     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3061     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3062     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3063
3064     state = 0xdeadbee;
3065     action = 0xdeadbee;
3066     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3067     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3068     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3069     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3070
3071     state = 0xdeadbee;
3072     action = 0xdeadbee;
3073     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3074     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3075     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3076     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3077
3078     state = 0xdeadbee;
3079     action = 0xdeadbee;
3080     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3081     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3082     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3083     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3084
3085     state = 0xdeadbee;
3086     action = 0xdeadbee;
3087     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3088     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3089     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3090     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3091
3092     state = 0xdeadbee;
3093     action = 0xdeadbee;
3094     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3095     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3096     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3097     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3098
3099     state = 0xdeadbee;
3100     action = 0xdeadbee;
3101     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3102     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3103     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3104     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3105
3106     state = 0xdeadbee;
3107     action = 0xdeadbee;
3108     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3109     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3110     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3111     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3112
3113     state = 0xdeadbee;
3114     action = 0xdeadbee;
3115     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3116     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3117     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3118     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3119
3120     state = 0xdeadbee;
3121     action = 0xdeadbee;
3122     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3123     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3124     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3125     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3126
3127     state = 0xdeadbee;
3128     action = 0xdeadbee;
3129     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3130     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3131     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3132     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3133
3134     state = 0xdeadbee;
3135     action = 0xdeadbee;
3136     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3137     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3138     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3139     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3140
3141     state = 0xdeadbee;
3142     action = 0xdeadbee;
3143     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3144     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3145     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3146     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3147
3148     state = 0xdeadbee;
3149     action = 0xdeadbee;
3150     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3151     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3152     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3153     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3154
3155     r = MsiDoAction( hpkg, "CostInitialize");
3156     ok( r == ERROR_SUCCESS, "cost init failed\n");
3157
3158     state = 0xdeadbee;
3159     action = 0xdeadbee;
3160     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3164
3165     state = 0xdeadbee;
3166     action = 0xdeadbee;
3167     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3171
3172     state = 0xdeadbee;
3173     action = 0xdeadbee;
3174     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3176     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3177     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3178
3179     state = 0xdeadbee;
3180     action = 0xdeadbee;
3181     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3182     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3183     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3184     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3185
3186     state = 0xdeadbee;
3187     action = 0xdeadbee;
3188     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3189     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3190     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3191     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3192
3193     state = 0xdeadbee;
3194     action = 0xdeadbee;
3195     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3196     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3197     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3198     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3199
3200     state = 0xdeadbee;
3201     action = 0xdeadbee;
3202     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3203     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3204     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3205     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3206
3207     state = 0xdeadbee;
3208     action = 0xdeadbee;
3209     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3210     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3211     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3212     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3213
3214     state = 0xdeadbee;
3215     action = 0xdeadbee;
3216     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3217     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3218     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3219     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3220
3221     state = 0xdeadbee;
3222     action = 0xdeadbee;
3223     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3224     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3225     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3226     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3227
3228     state = 0xdeadbee;
3229     action = 0xdeadbee;
3230     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3232     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3233     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3234
3235     state = 0xdeadbee;
3236     action = 0xdeadbee;
3237     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3239     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3240     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3241
3242     state = 0xdeadbee;
3243     action = 0xdeadbee;
3244     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3246     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3247     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3248
3249     state = 0xdeadbee;
3250     action = 0xdeadbee;
3251     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3252     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3253     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3254     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3255
3256     state = 0xdeadbee;
3257     action = 0xdeadbee;
3258     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3259     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3260     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3261     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3262
3263     state = 0xdeadbee;
3264     action = 0xdeadbee;
3265     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3266     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3267     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3268     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3269
3270     state = 0xdeadbee;
3271     action = 0xdeadbee;
3272     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3273     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3274     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3275     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3276
3277     state = 0xdeadbee;
3278     action = 0xdeadbee;
3279     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3280     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3281     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3282     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3283
3284     state = 0xdeadbee;
3285     action = 0xdeadbee;
3286     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3287     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3288     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3289     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3290
3291     state = 0xdeadbee;
3292     action = 0xdeadbee;
3293     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3294     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3295     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3296     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3297
3298     state = 0xdeadbee;
3299     action = 0xdeadbee;
3300     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3301     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3302     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3303     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3304
3305     state = 0xdeadbee;
3306     action = 0xdeadbee;
3307     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3308     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3309     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3310     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3311
3312     state = 0xdeadbee;
3313     action = 0xdeadbee;
3314     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3315     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3316     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3317     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3318
3319     state = 0xdeadbee;
3320     action = 0xdeadbee;
3321     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3322     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3323     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3324     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3325
3326     state = 0xdeadbee;
3327     action = 0xdeadbee;
3328     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3329     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3330     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3331     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3332
3333     state = 0xdeadbee;
3334     action = 0xdeadbee;
3335     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3336     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3337     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3338     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3339
3340     state = 0xdeadbee;
3341     action = 0xdeadbee;
3342     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3343     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3344     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3345     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3346
3347     state = 0xdeadbee;
3348     action = 0xdeadbee;
3349     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3350     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3351     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3352     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3353
3354     state = 0xdeadbee;
3355     action = 0xdeadbee;
3356     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3357     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3358     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3359     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3360
3361     state = 0xdeadbee;
3362     action = 0xdeadbee;
3363     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3364     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3365     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3366     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3367
3368     state = 0xdeadbee;
3369     action = 0xdeadbee;
3370     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3371     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3372     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3373     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3374
3375     state = 0xdeadbee;
3376     action = 0xdeadbee;
3377     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3378     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3379     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3380     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3381
3382     state = 0xdeadbee;
3383     action = 0xdeadbee;
3384     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3385     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3386     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3387     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3388
3389     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3390
3391     r = MsiDoAction( hpkg, "FileCost");
3392     ok( r == ERROR_SUCCESS, "file cost failed\n");
3393
3394     r = MsiGetFeatureState(hpkg, "one", NULL, NULL);
3395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3396
3397     action = 0xdeadbee;
3398     r = MsiGetFeatureState(hpkg, "one", NULL, &action);
3399     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3400     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3401
3402     state = 0xdeadbee;
3403     r = MsiGetFeatureState( hpkg, "one", &state, NULL);
3404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3406
3407     state = 0xdeadbee;
3408     action = 0xdeadbee;
3409     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3410     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3411     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3412     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3413
3414     state = 0xdeadbee;
3415     action = 0xdeadbee;
3416     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3417     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3418     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3419     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3420
3421     state = 0xdeadbee;
3422     action = 0xdeadbee;
3423     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3424     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3425     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3426     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3427
3428     state = 0xdeadbee;
3429     action = 0xdeadbee;
3430     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3431     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3432     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3433     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3434
3435     state = 0xdeadbee;
3436     action = 0xdeadbee;
3437     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3438     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3439     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3440     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3441
3442     state = 0xdeadbee;
3443     action = 0xdeadbee;
3444     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3445     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3446     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3447     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3448
3449     state = 0xdeadbee;
3450     action = 0xdeadbee;
3451     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3452     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3453     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3454     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3455
3456     state = 0xdeadbee;
3457     action = 0xdeadbee;
3458     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3459     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3460     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3461     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3462
3463     state = 0xdeadbee;
3464     action = 0xdeadbee;
3465     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3466     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3467     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3468     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3469
3470     state = 0xdeadbee;
3471     action = 0xdeadbee;
3472     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3473     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3474     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3475     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3476
3477     state = 0xdeadbee;
3478     action = 0xdeadbee;
3479     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3480     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3481     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3482     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3483
3484     state = 0xdeadbee;
3485     action = 0xdeadbee;
3486     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3487     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3488     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3489     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3490
3491     state = 0xdeadbee;
3492     action = 0xdeadbee;
3493     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3494     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3495     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3496     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3497
3498     state = 0xdeadbee;
3499     action = 0xdeadbee;
3500     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3501     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3502     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3503     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3504
3505     state = 0xdeadbee;
3506     action = 0xdeadbee;
3507     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3508     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3509     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3510     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3511
3512     state = 0xdeadbee;
3513     action = 0xdeadbee;
3514     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3515     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3516     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3517     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3518
3519     state = 0xdeadbee;
3520     action = 0xdeadbee;
3521     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3522     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3523     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3524     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3525
3526     state = 0xdeadbee;
3527     action = 0xdeadbee;
3528     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3529     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3530     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3531     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3532
3533     state = 0xdeadbee;
3534     action = 0xdeadbee;
3535     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3536     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3537     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3538     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3539
3540     state = 0xdeadbee;
3541     action = 0xdeadbee;
3542     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3543     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3544     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3545     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3546
3547     state = 0xdeadbee;
3548     action = 0xdeadbee;
3549     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3550     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3551     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3552     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3553
3554     state = 0xdeadbee;
3555     action = 0xdeadbee;
3556     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3557     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3558     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3559     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3560
3561     state = 0xdeadbee;
3562     action = 0xdeadbee;
3563     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3564     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3565     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3566     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3567
3568     state = 0xdeadbee;
3569     action = 0xdeadbee;
3570     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3571     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3572     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3573     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3574
3575     state = 0xdeadbee;
3576     action = 0xdeadbee;
3577     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3578     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3579     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3580     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3581
3582     state = 0xdeadbee;
3583     action = 0xdeadbee;
3584     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3585     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3586     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3587     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3588
3589     state = 0xdeadbee;
3590     action = 0xdeadbee;
3591     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3592     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3593     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3594     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3595
3596     state = 0xdeadbee;
3597     action = 0xdeadbee;
3598     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3599     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3600     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3601     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3602
3603     state = 0xdeadbee;
3604     action = 0xdeadbee;
3605     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3606     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3607     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3608     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3609
3610     state = 0xdeadbee;
3611     action = 0xdeadbee;
3612     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3613     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3614     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3615     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3616
3617     state = 0xdeadbee;
3618     action = 0xdeadbee;
3619     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3620     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3621     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3622     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3623
3624     state = 0xdeadbee;
3625     action = 0xdeadbee;
3626     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3627     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3628     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3629     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3630
3631     state = 0xdeadbee;
3632     action = 0xdeadbee;
3633     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3635     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3636     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3637
3638     r = MsiDoAction( hpkg, "CostFinalize");
3639     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3640
3641     state = 0xdeadbee;
3642     action = 0xdeadbee;
3643     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3644     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3645     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3646     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3647
3648     state = 0xdeadbee;
3649     action = 0xdeadbee;
3650     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3651     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3652     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3653     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3654
3655     state = 0xdeadbee;
3656     action = 0xdeadbee;
3657     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3658     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3659     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3660     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3661
3662     state = 0xdeadbee;
3663     action = 0xdeadbee;
3664     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3665     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3666     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3667     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3668
3669     state = 0xdeadbee;
3670     action = 0xdeadbee;
3671     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3672     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3673     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3674     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3675
3676     state = 0xdeadbee;
3677     action = 0xdeadbee;
3678     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3679     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3680     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3681     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3682
3683     state = 0xdeadbee;
3684     action = 0xdeadbee;
3685     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3686     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3687     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3688     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3689
3690     state = 0xdeadbee;
3691     action = 0xdeadbee;
3692     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3693     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3694     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3695     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3696
3697     state = 0xdeadbee;
3698     action = 0xdeadbee;
3699     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3700     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3701     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3702     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3703
3704     state = 0xdeadbee;
3705     action = 0xdeadbee;
3706     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3707     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3708     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3709     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3710
3711     state = 0xdeadbee;
3712     action = 0xdeadbee;
3713     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3714     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3715     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3716     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3717
3718     state = 0xdeadbee;
3719     action = 0xdeadbee;
3720     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3721     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3722     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3723     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3724
3725     state = 0xdeadbee;
3726     action = 0xdeadbee;
3727     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3728     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3729     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3730     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3731
3732     state = 0xdeadbee;
3733     action = 0xdeadbee;
3734     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3735     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3736     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3737     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3738
3739     state = 0xdeadbee;
3740     action = 0xdeadbee;
3741     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3742     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3743     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3744     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3745
3746     state = 0xdeadbee;
3747     action = 0xdeadbee;
3748     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3749     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3750     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3751     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3752
3753     state = 0xdeadbee;
3754     action = 0xdeadbee;
3755     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3756     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3757     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3758     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3759
3760     state = 0xdeadbee;
3761     action = 0xdeadbee;
3762     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3763     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3764     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3765     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3766
3767     state = 0xdeadbee;
3768     action = 0xdeadbee;
3769     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3770     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3771     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3772     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3773
3774     state = 0xdeadbee;
3775     action = 0xdeadbee;
3776     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3777     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3778     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3779     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3780
3781     state = 0xdeadbee;
3782     action = 0xdeadbee;
3783     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3784     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3785     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3786     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3787
3788     state = 0xdeadbee;
3789     action = 0xdeadbee;
3790     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3791     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3792     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3793     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3794
3795     state = 0xdeadbee;
3796     action = 0xdeadbee;
3797     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3798     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3799     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3800     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3801
3802     state = 0xdeadbee;
3803     action = 0xdeadbee;
3804     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3805     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3806     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3807     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3808
3809     state = 0xdeadbee;
3810     action = 0xdeadbee;
3811     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3812     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3813     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3814     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3815
3816     state = 0xdeadbee;
3817     action = 0xdeadbee;
3818     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3819     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3820     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3821     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3822
3823     state = 0xdeadbee;
3824     action = 0xdeadbee;
3825     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3826     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3827     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3828     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3829
3830     state = 0xdeadbee;
3831     action = 0xdeadbee;
3832     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3833     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3834     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3835     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3836
3837     state = 0xdeadbee;
3838     action = 0xdeadbee;
3839     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3840     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3841     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3842     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3843
3844     state = 0xdeadbee;
3845     action = 0xdeadbee;
3846     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3847     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3848     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3849     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3850
3851     state = 0xdeadbee;
3852     action = 0xdeadbee;
3853     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3854     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3855     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3856     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3857
3858     state = 0xdeadbee;
3859     action = 0xdeadbee;
3860     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3861     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3862     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3863     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3864
3865     state = 0xdeadbee;
3866     action = 0xdeadbee;
3867     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3868     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3869     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3870     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3871
3872     MsiCloseHandle( hpkg );
3873
3874     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3875
3876     /* publish the features and components */
3877     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3878     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3879
3880     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3881     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3882
3883     /* these properties must not be in the saved msi file */
3884     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3885     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3886
3887     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3888     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3889
3890     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3891     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3892
3893     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3894     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3895
3896     r = package_from_db( hdb, &hpkg );
3897     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3898
3899     MsiCloseHandle(hdb);
3900
3901     state = 0xdeadbee;
3902     action = 0xdeadbee;
3903     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3904     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3905     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3906     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3907
3908     state = 0xdeadbee;
3909     action = 0xdeadbee;
3910     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3911     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3912     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3913     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3914
3915     state = 0xdeadbee;
3916     action = 0xdeadbee;
3917     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3918     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3919     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3920     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3921
3922     state = 0xdeadbee;
3923     action = 0xdeadbee;
3924     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3925     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3926     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3927     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3928
3929     state = 0xdeadbee;
3930     action = 0xdeadbee;
3931     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3932     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3933     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3934     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3935
3936     state = 0xdeadbee;
3937     action = 0xdeadbee;
3938     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3939     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3940     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3941     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3942
3943     state = 0xdeadbee;
3944     action = 0xdeadbee;
3945     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3946     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3947     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3948     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3949
3950     state = 0xdeadbee;
3951     action = 0xdeadbee;
3952     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3953     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3954     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3955     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3956
3957     state = 0xdeadbee;
3958     action = 0xdeadbee;
3959     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3960     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3961     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3962     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3963
3964     state = 0xdeadbee;
3965     action = 0xdeadbee;
3966     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3967     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3968     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3969     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3970
3971     state = 0xdeadbee;
3972     action = 0xdeadbee;
3973     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3974     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3975     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3976     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3977
3978     state = 0xdeadbee;
3979     action = 0xdeadbee;
3980     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3981     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3982     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3983     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3984
3985     state = 0xdeadbee;
3986     action = 0xdeadbee;
3987     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3988     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3989     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3990     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3991
3992     state = 0xdeadbee;
3993     action = 0xdeadbee;
3994     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3995     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3996     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3997     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3998
3999     state = 0xdeadbee;
4000     action = 0xdeadbee;
4001     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4002     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4003     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4004     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4005
4006     state = 0xdeadbee;
4007     action = 0xdeadbee;
4008     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4009     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4010     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4011     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4012
4013     state = 0xdeadbee;
4014     action = 0xdeadbee;
4015     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4016     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4017     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4018     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4019
4020     state = 0xdeadbee;
4021     action = 0xdeadbee;
4022     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4023     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4024     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4025     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4026
4027     state = 0xdeadbee;
4028     action = 0xdeadbee;
4029     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4030     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4031     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4032     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4033
4034     state = 0xdeadbee;
4035     action = 0xdeadbee;
4036     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4037     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4038     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4039     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4040
4041     state = 0xdeadbee;
4042     action = 0xdeadbee;
4043     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4044     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4045     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4046     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4047
4048     state = 0xdeadbee;
4049     action = 0xdeadbee;
4050     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4051     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4052     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4053     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4054
4055     state = 0xdeadbee;
4056     action = 0xdeadbee;
4057     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4058     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4059     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4060     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4061
4062     state = 0xdeadbee;
4063     action = 0xdeadbee;
4064     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4065     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4066     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4067     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4068
4069     state = 0xdeadbee;
4070     action = 0xdeadbee;
4071     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4072     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4073     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4074     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4075
4076     state = 0xdeadbee;
4077     action = 0xdeadbee;
4078     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4079     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4080     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4081     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4082
4083     state = 0xdeadbee;
4084     action = 0xdeadbee;
4085     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4086     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4087     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4088     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4089
4090     state = 0xdeadbee;
4091     action = 0xdeadbee;
4092     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4093     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4094     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4095     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4096
4097     state = 0xdeadbee;
4098     action = 0xdeadbee;
4099     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4100     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4101     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4102     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4103
4104     state = 0xdeadbee;
4105     action = 0xdeadbee;
4106     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4107     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4108     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4109     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4110
4111     state = 0xdeadbee;
4112     action = 0xdeadbee;
4113     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4114     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4115     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4116     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4117
4118     state = 0xdeadbee;
4119     action = 0xdeadbee;
4120     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4121     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4122     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4123     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4124
4125     state = 0xdeadbee;
4126     action = 0xdeadbee;
4127     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4128     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4129     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4130     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4131
4132     r = MsiDoAction( hpkg, "CostInitialize");
4133     ok( r == ERROR_SUCCESS, "cost init failed\n");
4134
4135     state = 0xdeadbee;
4136     action = 0xdeadbee;
4137     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4138     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4139     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4140     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4141
4142     state = 0xdeadbee;
4143     action = 0xdeadbee;
4144     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4146     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4147     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4148
4149     state = 0xdeadbee;
4150     action = 0xdeadbee;
4151     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4152     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4153     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4154     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4155
4156     state = 0xdeadbee;
4157     action = 0xdeadbee;
4158     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4160     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4161     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4162
4163     state = 0xdeadbee;
4164     action = 0xdeadbee;
4165     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4167     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4168     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4169
4170     state = 0xdeadbee;
4171     action = 0xdeadbee;
4172     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4174     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4175     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4176
4177     state = 0xdeadbee;
4178     action = 0xdeadbee;
4179     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4181     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4182     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4183
4184     state = 0xdeadbee;
4185     action = 0xdeadbee;
4186     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4188     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4189     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4190
4191     state = 0xdeadbee;
4192     action = 0xdeadbee;
4193     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4195     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4196     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4197
4198     state = 0xdeadbee;
4199     action = 0xdeadbee;
4200     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4202     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4203     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4204
4205     state = 0xdeadbee;
4206     action = 0xdeadbee;
4207     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4209     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4210     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4211
4212     state = 0xdeadbee;
4213     action = 0xdeadbee;
4214     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4216     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4217     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4218
4219     state = 0xdeadbee;
4220     action = 0xdeadbee;
4221     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4223     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4224     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4225
4226     state = 0xdeadbee;
4227     action = 0xdeadbee;
4228     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4230     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4231     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4232
4233     state = 0xdeadbee;
4234     action = 0xdeadbee;
4235     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4237     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4238     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4239
4240     state = 0xdeadbee;
4241     action = 0xdeadbee;
4242     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4243     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4244     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4245     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4246
4247     state = 0xdeadbee;
4248     action = 0xdeadbee;
4249     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4250     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4251     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4252     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4253
4254     state = 0xdeadbee;
4255     action = 0xdeadbee;
4256     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4257     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4258     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4259     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4260
4261     state = 0xdeadbee;
4262     action = 0xdeadbee;
4263     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4264     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4265     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4266     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4267
4268     state = 0xdeadbee;
4269     action = 0xdeadbee;
4270     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4271     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4272     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4273     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4274
4275     state = 0xdeadbee;
4276     action = 0xdeadbee;
4277     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4278     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4279     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4280     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4281
4282     state = 0xdeadbee;
4283     action = 0xdeadbee;
4284     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4285     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4286     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4287     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4288
4289     state = 0xdeadbee;
4290     action = 0xdeadbee;
4291     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4292     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4293     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4294     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4295
4296     state = 0xdeadbee;
4297     action = 0xdeadbee;
4298     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4299     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4300     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4301     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4302
4303     state = 0xdeadbee;
4304     action = 0xdeadbee;
4305     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4306     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4307     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4308     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4309
4310     state = 0xdeadbee;
4311     action = 0xdeadbee;
4312     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4313     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4314     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4315     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4316
4317     state = 0xdeadbee;
4318     action = 0xdeadbee;
4319     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4320     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4321     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4322     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4323
4324     state = 0xdeadbee;
4325     action = 0xdeadbee;
4326     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4327     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4328     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4329     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4330
4331     state = 0xdeadbee;
4332     action = 0xdeadbee;
4333     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4334     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4335     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4336     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4337
4338     state = 0xdeadbee;
4339     action = 0xdeadbee;
4340     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4341     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4342     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4343     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4344
4345     state = 0xdeadbee;
4346     action = 0xdeadbee;
4347     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4348     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4349     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4350     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4351
4352     state = 0xdeadbee;
4353     action = 0xdeadbee;
4354     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4355     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4356     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4357     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4358
4359     state = 0xdeadbee;
4360     action = 0xdeadbee;
4361     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4362     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4363     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4364     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4365
4366     r = MsiDoAction( hpkg, "FileCost");
4367     ok( r == ERROR_SUCCESS, "file cost failed\n");
4368
4369     state = 0xdeadbee;
4370     action = 0xdeadbee;
4371     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4372     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4373     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4374     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4375
4376     state = 0xdeadbee;
4377     action = 0xdeadbee;
4378     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4379     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4380     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4381     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4382
4383     state = 0xdeadbee;
4384     action = 0xdeadbee;
4385     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4386     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4387     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4388     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4389
4390     state = 0xdeadbee;
4391     action = 0xdeadbee;
4392     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4393     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4394     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4395     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4396
4397     state = 0xdeadbee;
4398     action = 0xdeadbee;
4399     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4400     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4401     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4402     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4403
4404     state = 0xdeadbee;
4405     action = 0xdeadbee;
4406     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4407     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4408     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4409     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4410
4411     state = 0xdeadbee;
4412     action = 0xdeadbee;
4413     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4414     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4415     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4416     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4417
4418     state = 0xdeadbee;
4419     action = 0xdeadbee;
4420     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4421     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4422     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4423     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4424
4425     state = 0xdeadbee;
4426     action = 0xdeadbee;
4427     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4428     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4429     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4430     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4431
4432     state = 0xdeadbee;
4433     action = 0xdeadbee;
4434     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4435     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4436     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4437     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4438
4439     state = 0xdeadbee;
4440     action = 0xdeadbee;
4441     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4442     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4443     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4444     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4445
4446     state = 0xdeadbee;
4447     action = 0xdeadbee;
4448     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4449     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4450     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4451     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4452
4453     state = 0xdeadbee;
4454     action = 0xdeadbee;
4455     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4457     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4458     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4459
4460     state = 0xdeadbee;
4461     action = 0xdeadbee;
4462     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4464     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4465     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4466
4467     state = 0xdeadbee;
4468     action = 0xdeadbee;
4469     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4471     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4472     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4473
4474     state = 0xdeadbee;
4475     action = 0xdeadbee;
4476     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4478     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4479     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4480
4481     state = 0xdeadbee;
4482     action = 0xdeadbee;
4483     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4485     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4486     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4487
4488     state = 0xdeadbee;
4489     action = 0xdeadbee;
4490     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4492     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4493     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4494
4495     state = 0xdeadbee;
4496     action = 0xdeadbee;
4497     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4499     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4500     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4501
4502     state = 0xdeadbee;
4503     action = 0xdeadbee;
4504     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4505     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4506     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4507     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4508
4509     state = 0xdeadbee;
4510     action = 0xdeadbee;
4511     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4513     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4514     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4515
4516     state = 0xdeadbee;
4517     action = 0xdeadbee;
4518     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4520     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4521     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4522
4523     state = 0xdeadbee;
4524     action = 0xdeadbee;
4525     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4527     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4528     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4529
4530     state = 0xdeadbee;
4531     action = 0xdeadbee;
4532     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4534     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4535     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4536
4537     state = 0xdeadbee;
4538     action = 0xdeadbee;
4539     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4541     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4542     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4543
4544     state = 0xdeadbee;
4545     action = 0xdeadbee;
4546     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4548     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4549     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4550
4551     state = 0xdeadbee;
4552     action = 0xdeadbee;
4553     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4555     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4556     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4557
4558     state = 0xdeadbee;
4559     action = 0xdeadbee;
4560     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4562     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4563     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4564
4565     state = 0xdeadbee;
4566     action = 0xdeadbee;
4567     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4569     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4570     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4571
4572     state = 0xdeadbee;
4573     action = 0xdeadbee;
4574     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4576     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4577     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4578
4579     state = 0xdeadbee;
4580     action = 0xdeadbee;
4581     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4583     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4584     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4585
4586     r = MsiDoAction( hpkg, "CostFinalize");
4587     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4588
4589     state = 0xdeadbee;
4590     action = 0xdeadbee;
4591     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4592     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4593     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4594     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4595
4596     state = 0xdeadbee;
4597     action = 0xdeadbee;
4598     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4599     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4600     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4601     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4602
4603     state = 0xdeadbee;
4604     action = 0xdeadbee;
4605     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4606     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4607     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4608     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4609
4610     state = 0xdeadbee;
4611     action = 0xdeadbee;
4612     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4613     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4614     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4615     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4616
4617     state = 0xdeadbee;
4618     action = 0xdeadbee;
4619     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4620     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4621     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4622     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4623
4624     state = 0xdeadbee;
4625     action = 0xdeadbee;
4626     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4627     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4628     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4629     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4630
4631     state = 0xdeadbee;
4632     action = 0xdeadbee;
4633     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4635     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4636     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4637
4638     state = 0xdeadbee;
4639     action = 0xdeadbee;
4640     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4641     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4642     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4643     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4644
4645     state = 0xdeadbee;
4646     action = 0xdeadbee;
4647     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4648     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4649     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4650     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4651
4652     state = 0xdeadbee;
4653     action = 0xdeadbee;
4654     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4655     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4656     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4657     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4658
4659     state = 0xdeadbee;
4660     action = 0xdeadbee;
4661     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4663     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4664     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4665
4666     state = 0xdeadbee;
4667     action = 0xdeadbee;
4668     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4669     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4670     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4671     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4672
4673     state = 0xdeadbee;
4674     action = 0xdeadbee;
4675     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4676     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4677     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4678     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4679
4680     state = 0xdeadbee;
4681     action = 0xdeadbee;
4682     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4683     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4684     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4685     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4686
4687     state = 0xdeadbee;
4688     action = 0xdeadbee;
4689     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4690     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4691     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4692     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4693
4694     state = 0xdeadbee;
4695     action = 0xdeadbee;
4696     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4697     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4698     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4699     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4700
4701     state = 0xdeadbee;
4702     action = 0xdeadbee;
4703     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4705     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4706     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4707
4708     state = 0xdeadbee;
4709     action = 0xdeadbee;
4710     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4712     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4713     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4714
4715     state = 0xdeadbee;
4716     action = 0xdeadbee;
4717     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4718     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4719     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4720     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4721
4722     state = 0xdeadbee;
4723     action = 0xdeadbee;
4724     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4725     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4726     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4727     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4728
4729     state = 0xdeadbee;
4730     action = 0xdeadbee;
4731     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4732     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4733     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4734     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4735
4736     state = 0xdeadbee;
4737     action = 0xdeadbee;
4738     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4739     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4740     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4741     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4742
4743     state = 0xdeadbee;
4744     action = 0xdeadbee;
4745     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4746     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4747     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4748     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4749
4750     state = 0xdeadbee;
4751     action = 0xdeadbee;
4752     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4753     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4754     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4755     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4756
4757     state = 0xdeadbee;
4758     action = 0xdeadbee;
4759     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4760     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4761     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4762     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4763
4764     state = 0xdeadbee;
4765     action = 0xdeadbee;
4766     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4767     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4768     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4769     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4770
4771     state = 0xdeadbee;
4772     action = 0xdeadbee;
4773     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4774     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4775     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4776     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4777
4778     state = 0xdeadbee;
4779     action = 0xdeadbee;
4780     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4781     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4782     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4783     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4784
4785     state = 0xdeadbee;
4786     action = 0xdeadbee;
4787     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4788     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4789     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4790     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4791
4792     state = 0xdeadbee;
4793     action = 0xdeadbee;
4794     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4795     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4796     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4797     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4798
4799     state = 0xdeadbee;
4800     action = 0xdeadbee;
4801     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4802     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4803     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4804     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4805
4806     state = 0xdeadbee;
4807     action = 0xdeadbee;
4808     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4809     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4810     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4811     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4812
4813     state = 0xdeadbee;
4814     action = 0xdeadbee;
4815     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4816     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4817     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4818     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4819
4820     MsiCloseHandle(hpkg);
4821
4822     /* uninstall the product */
4823     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4824     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4825
4826     /* all features installed locally */
4827     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4829
4830     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4831     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4832
4833     /* these properties must not be in the saved msi file */
4834     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4835     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4836
4837     r = package_from_db( hdb, &hpkg );
4838     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
4839
4840     state = 0xdeadbee;
4841     action = 0xdeadbee;
4842     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4843     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4844     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4845     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4846
4847     state = 0xdeadbee;
4848     action = 0xdeadbee;
4849     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4850     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4851     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4852     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4853
4854     state = 0xdeadbee;
4855     action = 0xdeadbee;
4856     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4857     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4858     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4859     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4860
4861     state = 0xdeadbee;
4862     action = 0xdeadbee;
4863     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4864     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4865     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4866     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4867
4868     state = 0xdeadbee;
4869     action = 0xdeadbee;
4870     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4871     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4872     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4873     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4874
4875     state = 0xdeadbee;
4876     action = 0xdeadbee;
4877     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4878     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4879     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4880     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4881
4882     state = 0xdeadbee;
4883     action = 0xdeadbee;
4884     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4885     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4886     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4887     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4888
4889     state = 0xdeadbee;
4890     action = 0xdeadbee;
4891     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4892     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4893     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4894     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4895
4896     state = 0xdeadbee;
4897     action = 0xdeadbee;
4898     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4899     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4900     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4901     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4902
4903     state = 0xdeadbee;
4904     action = 0xdeadbee;
4905     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4906     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4907     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4908     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4909
4910     state = 0xdeadbee;
4911     action = 0xdeadbee;
4912     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4913     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4914     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4915     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4916
4917     state = 0xdeadbee;
4918     action = 0xdeadbee;
4919     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4920     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4921     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4922     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4923
4924     state = 0xdeadbee;
4925     action = 0xdeadbee;
4926     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4927     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4928     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4929     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4930
4931     state = 0xdeadbee;
4932     action = 0xdeadbee;
4933     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4934     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4935     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4936     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4937
4938     state = 0xdeadbee;
4939     action = 0xdeadbee;
4940     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4941     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4942     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4943     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4944
4945     state = 0xdeadbee;
4946     action = 0xdeadbee;
4947     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4948     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4949     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4950     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4951
4952     state = 0xdeadbee;
4953     action = 0xdeadbee;
4954     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4955     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4956     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4957     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4958
4959     state = 0xdeadbee;
4960     action = 0xdeadbee;
4961     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4962     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4963     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4964     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4965
4966     state = 0xdeadbee;
4967     action = 0xdeadbee;
4968     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4969     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4970     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4971     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4972
4973     state = 0xdeadbee;
4974     action = 0xdeadbee;
4975     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4976     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4977     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4978     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4979
4980     state = 0xdeadbee;
4981     action = 0xdeadbee;
4982     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4983     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4984     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4985     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4986
4987     state = 0xdeadbee;
4988     action = 0xdeadbee;
4989     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4990     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4991     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4992     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4993
4994     state = 0xdeadbee;
4995     action = 0xdeadbee;
4996     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4997     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4998     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4999     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5000
5001     state = 0xdeadbee;
5002     action = 0xdeadbee;
5003     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5004     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5005     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5006     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5007
5008     state = 0xdeadbee;
5009     action = 0xdeadbee;
5010     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5011     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5012     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5013     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5014
5015     state = 0xdeadbee;
5016     action = 0xdeadbee;
5017     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5018     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5019     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5020     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5021
5022     state = 0xdeadbee;
5023     action = 0xdeadbee;
5024     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5025     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5026     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5027     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5028
5029     state = 0xdeadbee;
5030     action = 0xdeadbee;
5031     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5032     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5033     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5034     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5035
5036     state = 0xdeadbee;
5037     action = 0xdeadbee;
5038     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5039     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5040     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5041     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5042
5043     state = 0xdeadbee;
5044     action = 0xdeadbee;
5045     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5046     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5047     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5048     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5049
5050     state = 0xdeadbee;
5051     action = 0xdeadbee;
5052     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5053     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5054     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5055     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5056
5057     state = 0xdeadbee;
5058     action = 0xdeadbee;
5059     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5060     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5061     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5062     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5063
5064     state = 0xdeadbee;
5065     action = 0xdeadbee;
5066     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5067     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5068     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5069     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5070
5071     r = MsiDoAction( hpkg, "CostInitialize");
5072     ok( r == ERROR_SUCCESS, "cost init failed\n");
5073
5074     state = 0xdeadbee;
5075     action = 0xdeadbee;
5076     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5080
5081     state = 0xdeadbee;
5082     action = 0xdeadbee;
5083     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5087
5088     state = 0xdeadbee;
5089     action = 0xdeadbee;
5090     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5094
5095     state = 0xdeadbee;
5096     action = 0xdeadbee;
5097     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5101
5102     state = 0xdeadbee;
5103     action = 0xdeadbee;
5104     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5108
5109     state = 0xdeadbee;
5110     action = 0xdeadbee;
5111     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5115
5116     state = 0xdeadbee;
5117     action = 0xdeadbee;
5118     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5122
5123     state = 0xdeadbee;
5124     action = 0xdeadbee;
5125     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5126     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5127     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5128     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5129
5130     state = 0xdeadbee;
5131     action = 0xdeadbee;
5132     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5134     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5135     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5136
5137     state = 0xdeadbee;
5138     action = 0xdeadbee;
5139     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5140     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5141     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5142     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5143
5144     state = 0xdeadbee;
5145     action = 0xdeadbee;
5146     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5147     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5148     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5149     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5150
5151     state = 0xdeadbee;
5152     action = 0xdeadbee;
5153     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5154     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5155     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5156     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5157
5158     state = 0xdeadbee;
5159     action = 0xdeadbee;
5160     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5164
5165     state = 0xdeadbee;
5166     action = 0xdeadbee;
5167     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5171
5172     state = 0xdeadbee;
5173     action = 0xdeadbee;
5174     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5176     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5177     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5178
5179     state = 0xdeadbee;
5180     action = 0xdeadbee;
5181     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5182     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5183     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5184     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5185
5186     state = 0xdeadbee;
5187     action = 0xdeadbee;
5188     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5189     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5190     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5191     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5192
5193     state = 0xdeadbee;
5194     action = 0xdeadbee;
5195     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5196     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5197     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5198     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5199
5200     state = 0xdeadbee;
5201     action = 0xdeadbee;
5202     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5203     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5204     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5205     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5206
5207     state = 0xdeadbee;
5208     action = 0xdeadbee;
5209     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5210     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5211     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5212     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5213
5214     state = 0xdeadbee;
5215     action = 0xdeadbee;
5216     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5217     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5218     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5219     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5220
5221     state = 0xdeadbee;
5222     action = 0xdeadbee;
5223     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5224     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5225     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5226     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5227
5228     state = 0xdeadbee;
5229     action = 0xdeadbee;
5230     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5232     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5233     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5234
5235     state = 0xdeadbee;
5236     action = 0xdeadbee;
5237     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5239     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5240     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5241
5242     state = 0xdeadbee;
5243     action = 0xdeadbee;
5244     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5246     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5247     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5248
5249     state = 0xdeadbee;
5250     action = 0xdeadbee;
5251     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5252     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5253     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5254     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5255
5256     state = 0xdeadbee;
5257     action = 0xdeadbee;
5258     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5259     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5260     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5261     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5262
5263     state = 0xdeadbee;
5264     action = 0xdeadbee;
5265     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5266     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5267     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5268     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5269
5270     state = 0xdeadbee;
5271     action = 0xdeadbee;
5272     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5273     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5274     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5275     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5276
5277     state = 0xdeadbee;
5278     action = 0xdeadbee;
5279     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5280     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5281     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5282     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5283
5284     state = 0xdeadbee;
5285     action = 0xdeadbee;
5286     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5287     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5288     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5289     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5290
5291     state = 0xdeadbee;
5292     action = 0xdeadbee;
5293     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5294     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5295     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5296     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5297
5298     state = 0xdeadbee;
5299     action = 0xdeadbee;
5300     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5301     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5302     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5303     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5304
5305     r = MsiDoAction( hpkg, "FileCost");
5306     ok( r == ERROR_SUCCESS, "file cost failed\n");
5307
5308     state = 0xdeadbee;
5309     action = 0xdeadbee;
5310     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5312     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5313     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5314
5315     state = 0xdeadbee;
5316     action = 0xdeadbee;
5317     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5319     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5320     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5321
5322     state = 0xdeadbee;
5323     action = 0xdeadbee;
5324     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5326     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5327     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5328
5329     state = 0xdeadbee;
5330     action = 0xdeadbee;
5331     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5333     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5334     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5335
5336     state = 0xdeadbee;
5337     action = 0xdeadbee;
5338     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5340     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5341     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5342
5343     state = 0xdeadbee;
5344     action = 0xdeadbee;
5345     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5347     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5348     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5349
5350     state = 0xdeadbee;
5351     action = 0xdeadbee;
5352     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5354     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5355     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5356
5357     state = 0xdeadbee;
5358     action = 0xdeadbee;
5359     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5361     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5362     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5363
5364     state = 0xdeadbee;
5365     action = 0xdeadbee;
5366     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5368     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5369     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5370
5371     state = 0xdeadbee;
5372     action = 0xdeadbee;
5373     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5375     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5376     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5377
5378     state = 0xdeadbee;
5379     action = 0xdeadbee;
5380     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5382     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5383     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5384
5385     state = 0xdeadbee;
5386     action = 0xdeadbee;
5387     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5388     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5389     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5390     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5391
5392     state = 0xdeadbee;
5393     action = 0xdeadbee;
5394     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5396     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5397     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5398
5399     state = 0xdeadbee;
5400     action = 0xdeadbee;
5401     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5402     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5403     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5404     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5405
5406     state = 0xdeadbee;
5407     action = 0xdeadbee;
5408     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5409     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5410     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5411     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5412
5413     state = 0xdeadbee;
5414     action = 0xdeadbee;
5415     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5416     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5417     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5418     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5419
5420     state = 0xdeadbee;
5421     action = 0xdeadbee;
5422     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5423     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5424     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5425     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5426
5427     state = 0xdeadbee;
5428     action = 0xdeadbee;
5429     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5430     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5431     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5432     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5433
5434     state = 0xdeadbee;
5435     action = 0xdeadbee;
5436     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5437     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5438     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5439     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5440
5441     state = 0xdeadbee;
5442     action = 0xdeadbee;
5443     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5444     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5445     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5446     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5447
5448     state = 0xdeadbee;
5449     action = 0xdeadbee;
5450     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5451     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5452     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5453     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5454
5455     state = 0xdeadbee;
5456     action = 0xdeadbee;
5457     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5458     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5459     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5460     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5461
5462     state = 0xdeadbee;
5463     action = 0xdeadbee;
5464     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5465     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5466     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5467     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5468
5469     state = 0xdeadbee;
5470     action = 0xdeadbee;
5471     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5472     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5473     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5474     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5475
5476     state = 0xdeadbee;
5477     action = 0xdeadbee;
5478     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5479     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5480     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5481     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5482
5483     state = 0xdeadbee;
5484     action = 0xdeadbee;
5485     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5486     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5487     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5488     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5489
5490     state = 0xdeadbee;
5491     action = 0xdeadbee;
5492     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5493     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5494     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5495     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5496
5497     state = 0xdeadbee;
5498     action = 0xdeadbee;
5499     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5500     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5501     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5502     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5503
5504     state = 0xdeadbee;
5505     action = 0xdeadbee;
5506     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5507     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5508     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5509     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5510
5511     state = 0xdeadbee;
5512     action = 0xdeadbee;
5513     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5514     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5515     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5516     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5517
5518     state = 0xdeadbee;
5519     action = 0xdeadbee;
5520     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5521     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5522     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5523     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5524
5525     state = 0xdeadbee;
5526     action = 0xdeadbee;
5527     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5528     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5529     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5530     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5531
5532     state = 0xdeadbee;
5533     action = 0xdeadbee;
5534     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5535     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5536     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5537     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5538
5539     r = MsiDoAction( hpkg, "CostFinalize");
5540     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5541
5542     state = 0xdeadbee;
5543     action = 0xdeadbee;
5544     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5545     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5546     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5547     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5548
5549     state = 0xdeadbee;
5550     action = 0xdeadbee;
5551     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5552     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5553     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5554     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5555
5556     state = 0xdeadbee;
5557     action = 0xdeadbee;
5558     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5559     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5560     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5561     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5562
5563     state = 0xdeadbee;
5564     action = 0xdeadbee;
5565     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5566     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5567     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5568     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5569
5570     state = 0xdeadbee;
5571     action = 0xdeadbee;
5572     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5573     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5574     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5575     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5576
5577     state = 0xdeadbee;
5578     action = 0xdeadbee;
5579     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5580     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5581     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5582     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5583
5584     state = 0xdeadbee;
5585     action = 0xdeadbee;
5586     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5587     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5588     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5589     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5590
5591     state = 0xdeadbee;
5592     action = 0xdeadbee;
5593     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5594     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5595     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5596     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5597
5598     state = 0xdeadbee;
5599     action = 0xdeadbee;
5600     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5601     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5602     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5603     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5604
5605     state = 0xdeadbee;
5606     action = 0xdeadbee;
5607     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5608     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5609     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5610     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5611
5612     state = 0xdeadbee;
5613     action = 0xdeadbee;
5614     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5615     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5616     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5617     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5618
5619     state = 0xdeadbee;
5620     action = 0xdeadbee;
5621     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5622     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5623     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5624     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5625
5626     state = 0xdeadbee;
5627     action = 0xdeadbee;
5628     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5629     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5630     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5631     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5632
5633     state = 0xdeadbee;
5634     action = 0xdeadbee;
5635     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5636     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5637     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5638     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5639
5640     state = 0xdeadbee;
5641     action = 0xdeadbee;
5642     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5643     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5644     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5645     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5646
5647     state = 0xdeadbee;
5648     action = 0xdeadbee;
5649     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5650     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5651     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5652     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5653
5654     state = 0xdeadbee;
5655     action = 0xdeadbee;
5656     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5657     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5658     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5659     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5660
5661     state = 0xdeadbee;
5662     action = 0xdeadbee;
5663     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5664     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5665     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5666     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5667
5668     state = 0xdeadbee;
5669     action = 0xdeadbee;
5670     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5671     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5672     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5673     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5674
5675     state = 0xdeadbee;
5676     action = 0xdeadbee;
5677     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5678     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5679     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5680     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5681
5682     state = 0xdeadbee;
5683     action = 0xdeadbee;
5684     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5685     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5686     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5687     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5688
5689     state = 0xdeadbee;
5690     action = 0xdeadbee;
5691     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5692     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5693     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5694     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5695
5696     state = 0xdeadbee;
5697     action = 0xdeadbee;
5698     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5699     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5700     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5701     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5702
5703     state = 0xdeadbee;
5704     action = 0xdeadbee;
5705     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5706     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5707     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5708     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5709
5710     state = 0xdeadbee;
5711     action = 0xdeadbee;
5712     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5713     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5714     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5715     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5716
5717     state = 0xdeadbee;
5718     action = 0xdeadbee;
5719     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5720     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5721     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5722     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5723
5724     state = 0xdeadbee;
5725     action = 0xdeadbee;
5726     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5727     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5728     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5729     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5730
5731     state = 0xdeadbee;
5732     action = 0xdeadbee;
5733     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5734     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5735     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5736     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5737
5738     state = 0xdeadbee;
5739     action = 0xdeadbee;
5740     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5741     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5742     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5743     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5744
5745     state = 0xdeadbee;
5746     action = 0xdeadbee;
5747     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5748     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5749     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5750     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5751
5752     state = 0xdeadbee;
5753     action = 0xdeadbee;
5754     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5755     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5756     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5757     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5758
5759     state = 0xdeadbee;
5760     action = 0xdeadbee;
5761     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5762     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5763     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5764     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5765
5766     state = 0xdeadbee;
5767     action = 0xdeadbee;
5768     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5769     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5770     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5771     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5772
5773     MsiCloseHandle(hpkg);
5774
5775     /* uninstall the product */
5776     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5777     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5778
5779     /* all features installed from source */
5780     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5781     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5782
5783     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5784     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5785
5786     /* this property must not be in the saved msi file */
5787     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5788     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5789
5790     r = package_from_db( hdb, &hpkg );
5791     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5792
5793     state = 0xdeadbee;
5794     action = 0xdeadbee;
5795     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5796     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5797     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5798     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5799
5800     state = 0xdeadbee;
5801     action = 0xdeadbee;
5802     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5803     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5804     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5805     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5806
5807     state = 0xdeadbee;
5808     action = 0xdeadbee;
5809     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5810     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5811     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5812     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5813
5814     state = 0xdeadbee;
5815     action = 0xdeadbee;
5816     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5817     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5818     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5819     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5820
5821     state = 0xdeadbee;
5822     action = 0xdeadbee;
5823     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5824     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5825     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5826     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5827
5828     state = 0xdeadbee;
5829     action = 0xdeadbee;
5830     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5831     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5832     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5833     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5834
5835     state = 0xdeadbee;
5836     action = 0xdeadbee;
5837     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5838     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5839     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5840     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5841
5842     state = 0xdeadbee;
5843     action = 0xdeadbee;
5844     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5845     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5846     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5847     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5848
5849     state = 0xdeadbee;
5850     action = 0xdeadbee;
5851     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5852     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5853     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5854     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5855
5856     state = 0xdeadbee;
5857     action = 0xdeadbee;
5858     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5859     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5860     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5861     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5862
5863     state = 0xdeadbee;
5864     action = 0xdeadbee;
5865     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5866     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5867     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5868     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5869
5870     state = 0xdeadbee;
5871     action = 0xdeadbee;
5872     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5873     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5874     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5875     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5876
5877     state = 0xdeadbee;
5878     action = 0xdeadbee;
5879     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5880     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5881     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5882     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5883
5884     state = 0xdeadbee;
5885     action = 0xdeadbee;
5886     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5887     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5888     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5889     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5890
5891     state = 0xdeadbee;
5892     action = 0xdeadbee;
5893     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5894     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5895     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5896     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5897
5898     state = 0xdeadbee;
5899     action = 0xdeadbee;
5900     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5901     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5902     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5903     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5904
5905     state = 0xdeadbee;
5906     action = 0xdeadbee;
5907     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5908     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5909     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5910     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5911
5912     state = 0xdeadbee;
5913     action = 0xdeadbee;
5914     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5915     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5916     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5917     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5918
5919     state = 0xdeadbee;
5920     action = 0xdeadbee;
5921     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5922     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5923     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5924     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5925
5926     state = 0xdeadbee;
5927     action = 0xdeadbee;
5928     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5929     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5930     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5931     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5932
5933     state = 0xdeadbee;
5934     action = 0xdeadbee;
5935     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5936     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5937     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5938     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5939
5940     state = 0xdeadbee;
5941     action = 0xdeadbee;
5942     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5943     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5944     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5945     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5946
5947     state = 0xdeadbee;
5948     action = 0xdeadbee;
5949     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5950     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5951     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5952     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5953
5954     state = 0xdeadbee;
5955     action = 0xdeadbee;
5956     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5957     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5958     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5959     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5960
5961     state = 0xdeadbee;
5962     action = 0xdeadbee;
5963     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5964     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5965     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5966     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5967
5968     state = 0xdeadbee;
5969     action = 0xdeadbee;
5970     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5971     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5972     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5973     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5974
5975     state = 0xdeadbee;
5976     action = 0xdeadbee;
5977     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5978     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5979     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5980     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5981
5982     state = 0xdeadbee;
5983     action = 0xdeadbee;
5984     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5985     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5986     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5987     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5988
5989     state = 0xdeadbee;
5990     action = 0xdeadbee;
5991     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5992     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5993     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5994     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5995
5996     state = 0xdeadbee;
5997     action = 0xdeadbee;
5998     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5999     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6000     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6001     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6002
6003     state = 0xdeadbee;
6004     action = 0xdeadbee;
6005     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6006     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6007     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6008     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6009
6010     state = 0xdeadbee;
6011     action = 0xdeadbee;
6012     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6013     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6014     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6015     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6016
6017     state = 0xdeadbee;
6018     action = 0xdeadbee;
6019     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6020     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6021     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6022     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6023
6024     r = MsiDoAction( hpkg, "CostInitialize");
6025     ok( r == ERROR_SUCCESS, "cost init failed\n");
6026
6027     state = 0xdeadbee;
6028     action = 0xdeadbee;
6029     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6030     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6031     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6032     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6033
6034     state = 0xdeadbee;
6035     action = 0xdeadbee;
6036     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6037     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6038     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6039     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6040
6041     state = 0xdeadbee;
6042     action = 0xdeadbee;
6043     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6045     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6046     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6047
6048     state = 0xdeadbee;
6049     action = 0xdeadbee;
6050     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6052     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6053     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6054
6055     state = 0xdeadbee;
6056     action = 0xdeadbee;
6057     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6059     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6060     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6061
6062     state = 0xdeadbee;
6063     action = 0xdeadbee;
6064     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6066     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6067     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6068
6069     state = 0xdeadbee;
6070     action = 0xdeadbee;
6071     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6072     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6073     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6074     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6075
6076     state = 0xdeadbee;
6077     action = 0xdeadbee;
6078     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6079     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6080     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6081     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6082
6083     state = 0xdeadbee;
6084     action = 0xdeadbee;
6085     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6086     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6087     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6088     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6089
6090     state = 0xdeadbee;
6091     action = 0xdeadbee;
6092     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6093     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6094     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6095     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6096
6097     state = 0xdeadbee;
6098     action = 0xdeadbee;
6099     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6101     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6102     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6103
6104     state = 0xdeadbee;
6105     action = 0xdeadbee;
6106     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6108     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6109     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6110
6111     state = 0xdeadbee;
6112     action = 0xdeadbee;
6113     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6115     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6116     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6117
6118     state = 0xdeadbee;
6119     action = 0xdeadbee;
6120     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6122     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6123     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6124
6125     state = 0xdeadbee;
6126     action = 0xdeadbee;
6127     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6129     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6130     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6131
6132     state = 0xdeadbee;
6133     action = 0xdeadbee;
6134     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6136     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6137     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6138
6139     state = 0xdeadbee;
6140     action = 0xdeadbee;
6141     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6143     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6144     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6145
6146     state = 0xdeadbee;
6147     action = 0xdeadbee;
6148     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6150     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6151     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6152
6153     state = 0xdeadbee;
6154     action = 0xdeadbee;
6155     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6157     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6158     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6159
6160     state = 0xdeadbee;
6161     action = 0xdeadbee;
6162     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6164     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6165     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6166
6167     state = 0xdeadbee;
6168     action = 0xdeadbee;
6169     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6171     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6172     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6173
6174     state = 0xdeadbee;
6175     action = 0xdeadbee;
6176     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6177     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6178     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6179     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6180
6181     state = 0xdeadbee;
6182     action = 0xdeadbee;
6183     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6184     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6185     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6186     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6187
6188     state = 0xdeadbee;
6189     action = 0xdeadbee;
6190     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6191     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6192     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6193     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6194
6195     state = 0xdeadbee;
6196     action = 0xdeadbee;
6197     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6198     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6199     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6200     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6201
6202     state = 0xdeadbee;
6203     action = 0xdeadbee;
6204     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6205     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6206     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6207     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6208
6209     state = 0xdeadbee;
6210     action = 0xdeadbee;
6211     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6212     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6213     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6214     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6215
6216     state = 0xdeadbee;
6217     action = 0xdeadbee;
6218     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6219     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6220     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6221     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6222
6223     state = 0xdeadbee;
6224     action = 0xdeadbee;
6225     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6226     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6227     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6228     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6229
6230     state = 0xdeadbee;
6231     action = 0xdeadbee;
6232     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6233     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6234     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6235     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6236
6237     state = 0xdeadbee;
6238     action = 0xdeadbee;
6239     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6240     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6241     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6242     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6243
6244     state = 0xdeadbee;
6245     action = 0xdeadbee;
6246     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6247     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6248     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6249     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6250
6251     state = 0xdeadbee;
6252     action = 0xdeadbee;
6253     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6254     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6255     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6256     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6257
6258     r = MsiDoAction( hpkg, "FileCost");
6259     ok( r == ERROR_SUCCESS, "file cost failed\n");
6260
6261     state = 0xdeadbee;
6262     action = 0xdeadbee;
6263     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6264     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6265     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6266     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6267
6268     state = 0xdeadbee;
6269     action = 0xdeadbee;
6270     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6271     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6272     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6273     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6274
6275     state = 0xdeadbee;
6276     action = 0xdeadbee;
6277     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6278     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6279     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6280     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6281
6282     state = 0xdeadbee;
6283     action = 0xdeadbee;
6284     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6285     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6286     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6287     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6288
6289     state = 0xdeadbee;
6290     action = 0xdeadbee;
6291     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6292     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6293     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6294     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6295
6296     state = 0xdeadbee;
6297     action = 0xdeadbee;
6298     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6299     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6300     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6301     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6302
6303     state = 0xdeadbee;
6304     action = 0xdeadbee;
6305     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6306     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6307     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6308     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6309
6310     state = 0xdeadbee;
6311     action = 0xdeadbee;
6312     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6313     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6314     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6315     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6316
6317     state = 0xdeadbee;
6318     action = 0xdeadbee;
6319     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6320     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6321     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6322     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6323
6324     state = 0xdeadbee;
6325     action = 0xdeadbee;
6326     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6327     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6328     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6329     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6330
6331     state = 0xdeadbee;
6332     action = 0xdeadbee;
6333     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6334     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6335     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6336     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6337
6338     state = 0xdeadbee;
6339     action = 0xdeadbee;
6340     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6341     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6342     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6343     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6344
6345     state = 0xdeadbee;
6346     action = 0xdeadbee;
6347     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6348     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6349     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6350     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6351
6352     state = 0xdeadbee;
6353     action = 0xdeadbee;
6354     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6355     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6356     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6357     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6358
6359     state = 0xdeadbee;
6360     action = 0xdeadbee;
6361     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6362     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6363     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6364     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6365
6366     state = 0xdeadbee;
6367     action = 0xdeadbee;
6368     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6369     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6370     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6371     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6372
6373     state = 0xdeadbee;
6374     action = 0xdeadbee;
6375     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6376     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6377     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6378     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6379
6380     state = 0xdeadbee;
6381     action = 0xdeadbee;
6382     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6383     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6384     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6385     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6386
6387     state = 0xdeadbee;
6388     action = 0xdeadbee;
6389     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6390     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6391     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6392     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6393
6394     state = 0xdeadbee;
6395     action = 0xdeadbee;
6396     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6397     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6398     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6399     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6400
6401     state = 0xdeadbee;
6402     action = 0xdeadbee;
6403     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6406     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6407
6408     state = 0xdeadbee;
6409     action = 0xdeadbee;
6410     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6411     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6412     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6413     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6414
6415     state = 0xdeadbee;
6416     action = 0xdeadbee;
6417     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6418     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6419     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6420     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6421
6422     state = 0xdeadbee;
6423     action = 0xdeadbee;
6424     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6425     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6426     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6427     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6428
6429     state = 0xdeadbee;
6430     action = 0xdeadbee;
6431     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6432     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6433     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6434     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6435
6436     state = 0xdeadbee;
6437     action = 0xdeadbee;
6438     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6439     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6440     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6441     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6442
6443     state = 0xdeadbee;
6444     action = 0xdeadbee;
6445     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6446     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6447     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6448     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6449
6450     state = 0xdeadbee;
6451     action = 0xdeadbee;
6452     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6453     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6454     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6455     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6456
6457     state = 0xdeadbee;
6458     action = 0xdeadbee;
6459     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6460     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6461     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6462     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6463
6464     state = 0xdeadbee;
6465     action = 0xdeadbee;
6466     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6468     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6469     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6470
6471     state = 0xdeadbee;
6472     action = 0xdeadbee;
6473     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6475     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6476     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6477
6478     state = 0xdeadbee;
6479     action = 0xdeadbee;
6480     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6482     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6483     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6484
6485     state = 0xdeadbee;
6486     action = 0xdeadbee;
6487     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6489     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6490     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6491
6492     r = MsiDoAction( hpkg, "CostFinalize");
6493     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6494
6495     state = 0xdeadbee;
6496     action = 0xdeadbee;
6497     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6499     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6500     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6501
6502     state = 0xdeadbee;
6503     action = 0xdeadbee;
6504     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6505     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6506     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6507     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6508
6509     state = 0xdeadbee;
6510     action = 0xdeadbee;
6511     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6513     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6514     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6515
6516     state = 0xdeadbee;
6517     action = 0xdeadbee;
6518     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6520     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6521     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6522
6523     state = 0xdeadbee;
6524     action = 0xdeadbee;
6525     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6527     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6528     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6529
6530     state = 0xdeadbee;
6531     action = 0xdeadbee;
6532     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6534     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6535     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6536
6537     state = 0xdeadbee;
6538     action = 0xdeadbee;
6539     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6541     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6542     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6543
6544     state = 0xdeadbee;
6545     action = 0xdeadbee;
6546     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6548     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6549     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6550
6551     state = 0xdeadbee;
6552     action = 0xdeadbee;
6553     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6555     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6556     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6557
6558     state = 0xdeadbee;
6559     action = 0xdeadbee;
6560     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6562     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6563     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6564
6565     state = 0xdeadbee;
6566     action = 0xdeadbee;
6567     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6569     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6570     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6571
6572     state = 0xdeadbee;
6573     action = 0xdeadbee;
6574     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6576     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6577     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6578
6579     state = 0xdeadbee;
6580     action = 0xdeadbee;
6581     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6583     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6584     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6585
6586     state = 0xdeadbee;
6587     action = 0xdeadbee;
6588     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6590     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6591     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6592
6593     state = 0xdeadbee;
6594     action = 0xdeadbee;
6595     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6597     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6598     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6599
6600     state = 0xdeadbee;
6601     action = 0xdeadbee;
6602     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6604     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6605     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6606
6607     state = 0xdeadbee;
6608     action = 0xdeadbee;
6609     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6611     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6612     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6613
6614     state = 0xdeadbee;
6615     action = 0xdeadbee;
6616     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6618     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6619     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6620
6621     state = 0xdeadbee;
6622     action = 0xdeadbee;
6623     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6625     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6626     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6627
6628     state = 0xdeadbee;
6629     action = 0xdeadbee;
6630     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6632     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6633     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6634
6635     state = 0xdeadbee;
6636     action = 0xdeadbee;
6637     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6639     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6640     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6641
6642     state = 0xdeadbee;
6643     action = 0xdeadbee;
6644     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6645     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6646     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6647     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6648
6649     state = 0xdeadbee;
6650     action = 0xdeadbee;
6651     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6653     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6654     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6655
6656     state = 0xdeadbee;
6657     action = 0xdeadbee;
6658     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6660     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6661     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6662
6663     state = 0xdeadbee;
6664     action = 0xdeadbee;
6665     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6667     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6668     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6669
6670     state = 0xdeadbee;
6671     action = 0xdeadbee;
6672     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6674     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6675     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6676
6677     state = 0xdeadbee;
6678     action = 0xdeadbee;
6679     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6681     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6682     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6683
6684     state = 0xdeadbee;
6685     action = 0xdeadbee;
6686     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6688     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6689     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6690
6691     state = 0xdeadbee;
6692     action = 0xdeadbee;
6693     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6695     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6696     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6697
6698     state = 0xdeadbee;
6699     action = 0xdeadbee;
6700     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6701     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6702     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6703     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6704
6705     state = 0xdeadbee;
6706     action = 0xdeadbee;
6707     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6708     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6709     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6710     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6711
6712     state = 0xdeadbee;
6713     action = 0xdeadbee;
6714     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6715     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6716     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6717     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6718
6719     state = 0xdeadbee;
6720     action = 0xdeadbee;
6721     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6722     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6723     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6724     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6725
6726     MsiCloseHandle(hpkg);
6727
6728     /* reinstall the product */
6729     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6731
6732     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6733     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6734
6735     /* this property must not be in the saved msi file */
6736     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6737     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6738
6739     r = package_from_db( hdb, &hpkg );
6740     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6741
6742     state = 0xdeadbee;
6743     action = 0xdeadbee;
6744     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6745     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6746     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6747     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6748
6749     state = 0xdeadbee;
6750     action = 0xdeadbee;
6751     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6752     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6753     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6754     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6755
6756     state = 0xdeadbee;
6757     action = 0xdeadbee;
6758     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6759     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6760     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6761     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6762
6763     state = 0xdeadbee;
6764     action = 0xdeadbee;
6765     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6766     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6767     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6768     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6769
6770     state = 0xdeadbee;
6771     action = 0xdeadbee;
6772     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6773     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6774     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6775     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6776
6777     state = 0xdeadbee;
6778     action = 0xdeadbee;
6779     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6780     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6781     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6782     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6783
6784     state = 0xdeadbee;
6785     action = 0xdeadbee;
6786     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6787     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6788     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6789     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6790
6791     state = 0xdeadbee;
6792     action = 0xdeadbee;
6793     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6794     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6795     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6796     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6797
6798     state = 0xdeadbee;
6799     action = 0xdeadbee;
6800     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6801     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6802     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6803     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6804
6805     state = 0xdeadbee;
6806     action = 0xdeadbee;
6807     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6808     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6809     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6810     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6811
6812     state = 0xdeadbee;
6813     action = 0xdeadbee;
6814     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6815     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6816     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6817     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6818
6819     state = 0xdeadbee;
6820     action = 0xdeadbee;
6821     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6822     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6823     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6824     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6825
6826     state = 0xdeadbee;
6827     action = 0xdeadbee;
6828     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6829     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6830     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6831     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6832
6833     state = 0xdeadbee;
6834     action = 0xdeadbee;
6835     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6836     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6837     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6838     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6839
6840     state = 0xdeadbee;
6841     action = 0xdeadbee;
6842     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6843     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6844     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6845     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6846
6847     state = 0xdeadbee;
6848     action = 0xdeadbee;
6849     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6850     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6851     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6852     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6853
6854     state = 0xdeadbee;
6855     action = 0xdeadbee;
6856     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6857     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6858     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6859     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6860
6861     state = 0xdeadbee;
6862     action = 0xdeadbee;
6863     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6864     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6865     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6866     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6867
6868     state = 0xdeadbee;
6869     action = 0xdeadbee;
6870     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6871     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6872     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6873     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6874
6875     state = 0xdeadbee;
6876     action = 0xdeadbee;
6877     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6878     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6879     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6880     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6881
6882     state = 0xdeadbee;
6883     action = 0xdeadbee;
6884     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6885     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6886     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6887     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6888
6889     state = 0xdeadbee;
6890     action = 0xdeadbee;
6891     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6892     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6893     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6894     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6895
6896     state = 0xdeadbee;
6897     action = 0xdeadbee;
6898     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6899     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6900     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6901     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6902
6903     state = 0xdeadbee;
6904     action = 0xdeadbee;
6905     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6906     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6907     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6908     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6909
6910     state = 0xdeadbee;
6911     action = 0xdeadbee;
6912     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6913     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6914     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6915     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6916
6917     state = 0xdeadbee;
6918     action = 0xdeadbee;
6919     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6920     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6921     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6922     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6923
6924     state = 0xdeadbee;
6925     action = 0xdeadbee;
6926     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6927     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6928     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6929     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6930
6931     state = 0xdeadbee;
6932     action = 0xdeadbee;
6933     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6934     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6935     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6936     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6937
6938     state = 0xdeadbee;
6939     action = 0xdeadbee;
6940     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6941     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6942     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6943     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6944
6945     state = 0xdeadbee;
6946     action = 0xdeadbee;
6947     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6948     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6949     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6950     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6951
6952     state = 0xdeadbee;
6953     action = 0xdeadbee;
6954     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6955     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6956     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6957     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6958
6959     state = 0xdeadbee;
6960     action = 0xdeadbee;
6961     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6962     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6963     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6964     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6965
6966     state = 0xdeadbee;
6967     action = 0xdeadbee;
6968     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6969     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6970     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6971     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6972
6973     r = MsiDoAction( hpkg, "CostInitialize");
6974     ok( r == ERROR_SUCCESS, "cost init failed\n");
6975
6976     state = 0xdeadbee;
6977     action = 0xdeadbee;
6978     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6979     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6980     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6981     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6982
6983     state = 0xdeadbee;
6984     action = 0xdeadbee;
6985     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6986     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6987     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6988     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6989
6990     state = 0xdeadbee;
6991     action = 0xdeadbee;
6992     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6993     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6994     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6995     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6996
6997     state = 0xdeadbee;
6998     action = 0xdeadbee;
6999     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7000     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7001     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7002     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7003
7004     state = 0xdeadbee;
7005     action = 0xdeadbee;
7006     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7007     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7008     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7009     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7010
7011     state = 0xdeadbee;
7012     action = 0xdeadbee;
7013     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7014     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7015     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7016     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7017
7018     state = 0xdeadbee;
7019     action = 0xdeadbee;
7020     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7021     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7022     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7023     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7024
7025     state = 0xdeadbee;
7026     action = 0xdeadbee;
7027     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7028     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7029     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7030     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7031
7032     state = 0xdeadbee;
7033     action = 0xdeadbee;
7034     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7035     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7036     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7037     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7038
7039     state = 0xdeadbee;
7040     action = 0xdeadbee;
7041     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7042     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7043     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7044     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7045
7046     state = 0xdeadbee;
7047     action = 0xdeadbee;
7048     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7049     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7050     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7051     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7052
7053     state = 0xdeadbee;
7054     action = 0xdeadbee;
7055     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7056     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7057     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7058     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7059
7060     state = 0xdeadbee;
7061     action = 0xdeadbee;
7062     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7063     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7064     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7065     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7066
7067     state = 0xdeadbee;
7068     action = 0xdeadbee;
7069     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7070     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7071     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7072     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7073
7074     state = 0xdeadbee;
7075     action = 0xdeadbee;
7076     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7080
7081     state = 0xdeadbee;
7082     action = 0xdeadbee;
7083     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7087
7088     state = 0xdeadbee;
7089     action = 0xdeadbee;
7090     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7094
7095     state = 0xdeadbee;
7096     action = 0xdeadbee;
7097     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7101
7102     state = 0xdeadbee;
7103     action = 0xdeadbee;
7104     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7108
7109     state = 0xdeadbee;
7110     action = 0xdeadbee;
7111     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7115
7116     state = 0xdeadbee;
7117     action = 0xdeadbee;
7118     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7122
7123     state = 0xdeadbee;
7124     action = 0xdeadbee;
7125     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7126     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7127     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7128     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7129
7130     state = 0xdeadbee;
7131     action = 0xdeadbee;
7132     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7134     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7135     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7136
7137     state = 0xdeadbee;
7138     action = 0xdeadbee;
7139     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7140     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7141     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7142     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7143
7144     state = 0xdeadbee;
7145     action = 0xdeadbee;
7146     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7147     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7148     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7149     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7150
7151     state = 0xdeadbee;
7152     action = 0xdeadbee;
7153     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7154     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7155     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7156     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7157
7158     state = 0xdeadbee;
7159     action = 0xdeadbee;
7160     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7164
7165     state = 0xdeadbee;
7166     action = 0xdeadbee;
7167     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7171
7172     state = 0xdeadbee;
7173     action = 0xdeadbee;
7174     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7176     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7177     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7178
7179     state = 0xdeadbee;
7180     action = 0xdeadbee;
7181     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7182     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7183     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7184     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7185
7186     state = 0xdeadbee;
7187     action = 0xdeadbee;
7188     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7189     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7190     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7191     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7192
7193     state = 0xdeadbee;
7194     action = 0xdeadbee;
7195     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7196     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7197     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7198     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7199
7200     state = 0xdeadbee;
7201     action = 0xdeadbee;
7202     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7203     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7204     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7205     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7206
7207     r = MsiDoAction( hpkg, "FileCost");
7208     ok( r == ERROR_SUCCESS, "file cost failed\n");
7209
7210     state = 0xdeadbee;
7211     action = 0xdeadbee;
7212     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7213     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7214     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7215     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7216
7217     state = 0xdeadbee;
7218     action = 0xdeadbee;
7219     r = MsiGetFeatureState(hpkg, "two", &state, &action);
7220     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7221     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7222     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7223
7224     state = 0xdeadbee;
7225     action = 0xdeadbee;
7226     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7227     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7228     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7229     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7230
7231     state = 0xdeadbee;
7232     action = 0xdeadbee;
7233     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7234     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7235     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7236     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7237
7238     state = 0xdeadbee;
7239     action = 0xdeadbee;
7240     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7241     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7242     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7243     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7244
7245     state = 0xdeadbee;
7246     action = 0xdeadbee;
7247     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7248     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7249     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7250     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7251
7252     state = 0xdeadbee;
7253     action = 0xdeadbee;
7254     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7255     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7256     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7257     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7258
7259     state = 0xdeadbee;
7260     action = 0xdeadbee;
7261     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7262     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7263     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7264     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7265
7266     state = 0xdeadbee;
7267     action = 0xdeadbee;
7268     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7269     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7270     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7271     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7272
7273     state = 0xdeadbee;
7274     action = 0xdeadbee;
7275     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7276     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7277     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7278     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7279
7280     state = 0xdeadbee;
7281     action = 0xdeadbee;
7282     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7283     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7284     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7285     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7286
7287     state = 0xdeadbee;
7288     action = 0xdeadbee;
7289     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7290     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7291     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7292     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7293
7294     state = 0xdeadbee;
7295     action = 0xdeadbee;
7296     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7297     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7298     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7299     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7300
7301     state = 0xdeadbee;
7302     action = 0xdeadbee;
7303     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7304     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7305     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7306     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7307
7308     state = 0xdeadbee;
7309     action = 0xdeadbee;
7310     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7312     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7313     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7314
7315     state = 0xdeadbee;
7316     action = 0xdeadbee;
7317     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7319     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7320     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7321
7322     state = 0xdeadbee;
7323     action = 0xdeadbee;
7324     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7326     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7327     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7328
7329     state = 0xdeadbee;
7330     action = 0xdeadbee;
7331     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7333     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7334     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7335
7336     state = 0xdeadbee;
7337     action = 0xdeadbee;
7338     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7340     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7341     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7342
7343     state = 0xdeadbee;
7344     action = 0xdeadbee;
7345     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7347     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7348     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7349
7350     state = 0xdeadbee;
7351     action = 0xdeadbee;
7352     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7354     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7355     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7356
7357     state = 0xdeadbee;
7358     action = 0xdeadbee;
7359     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7361     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7362     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7363
7364     state = 0xdeadbee;
7365     action = 0xdeadbee;
7366     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7368     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7369     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7370
7371     state = 0xdeadbee;
7372     action = 0xdeadbee;
7373     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7375     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7376     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7377
7378     state = 0xdeadbee;
7379     action = 0xdeadbee;
7380     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7382     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7383     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7384
7385     state = 0xdeadbee;
7386     action = 0xdeadbee;
7387     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7388     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7389     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7390     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7391
7392     state = 0xdeadbee;
7393     action = 0xdeadbee;
7394     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7396     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7397     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7398
7399     state = 0xdeadbee;
7400     action = 0xdeadbee;
7401     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7402     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7403     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7404     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7405
7406     state = 0xdeadbee;
7407     action = 0xdeadbee;
7408     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7409     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7410     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7411     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7412
7413     state = 0xdeadbee;
7414     action = 0xdeadbee;
7415     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7416     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7417     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7418     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7419
7420     state = 0xdeadbee;
7421     action = 0xdeadbee;
7422     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7423     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7424     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7425     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7426
7427     state = 0xdeadbee;
7428     action = 0xdeadbee;
7429     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7430     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7431     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7432     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7433
7434     state = 0xdeadbee;
7435     action = 0xdeadbee;
7436     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7437     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7438     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7439     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7440
7441     r = MsiDoAction( hpkg, "CostFinalize");
7442     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
7443
7444     state = 0xdeadbee;
7445     action = 0xdeadbee;
7446     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7448     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7449     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7450
7451     state = 0xdeadbee;
7452     action = 0xdeadbee;
7453     r = MsiGetFeatureState(hpkg, "two", &state, &action);
7454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7455     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7456     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7457
7458     state = 0xdeadbee;
7459     action = 0xdeadbee;
7460     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7461     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7462     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7463     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7464
7465     state = 0xdeadbee;
7466     action = 0xdeadbee;
7467     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7468     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7469     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7470     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7471
7472     state = 0xdeadbee;
7473     action = 0xdeadbee;
7474     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7475     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7476     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7477     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7478
7479     state = 0xdeadbee;
7480     action = 0xdeadbee;
7481     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7482     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7483     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7484     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7485
7486     state = 0xdeadbee;
7487     action = 0xdeadbee;
7488     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7489     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7490     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7491     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7492
7493     state = 0xdeadbee;
7494     action = 0xdeadbee;
7495     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7496     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7497     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7498     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7499
7500     state = 0xdeadbee;
7501     action = 0xdeadbee;
7502     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7503     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7504     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7505     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7506
7507     state = 0xdeadbee;
7508     action = 0xdeadbee;
7509     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7510     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7511     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7512     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7513
7514     state = 0xdeadbee;
7515     action = 0xdeadbee;
7516     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7517     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7518     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7519     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7520
7521     state = 0xdeadbee;
7522     action = 0xdeadbee;
7523     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7524     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7525     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7526     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7527
7528     state = 0xdeadbee;
7529     action = 0xdeadbee;
7530     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7531     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7532     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7533     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7534
7535     state = 0xdeadbee;
7536     action = 0xdeadbee;
7537     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7538     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7539     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7540     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7541
7542     state = 0xdeadbee;
7543     action = 0xdeadbee;
7544     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7545     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7546     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7547     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7548
7549     state = 0xdeadbee;
7550     action = 0xdeadbee;
7551     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7552     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7553     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7554     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7555
7556     state = 0xdeadbee;
7557     action = 0xdeadbee;
7558     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7559     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7560     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7561     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7562
7563     state = 0xdeadbee;
7564     action = 0xdeadbee;
7565     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7566     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7567     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7568     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7569
7570     state = 0xdeadbee;
7571     action = 0xdeadbee;
7572     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7573     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7574     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7575     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7576
7577     state = 0xdeadbee;
7578     action = 0xdeadbee;
7579     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7580     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7581     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7582     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7583
7584     state = 0xdeadbee;
7585     action = 0xdeadbee;
7586     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7587     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7588     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7589     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7590
7591     state = 0xdeadbee;
7592     action = 0xdeadbee;
7593     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7594     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7595     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7596     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7597
7598     state = 0xdeadbee;
7599     action = 0xdeadbee;
7600     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7601     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7602     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7603     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7604
7605     state = 0xdeadbee;
7606     action = 0xdeadbee;
7607     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7608     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7609     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7610     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7611
7612     state = 0xdeadbee;
7613     action = 0xdeadbee;
7614     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7615     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7616     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7617     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7618
7619     state = 0xdeadbee;
7620     action = 0xdeadbee;
7621     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7622     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7623     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7624     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7625
7626     state = 0xdeadbee;
7627     action = 0xdeadbee;
7628     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7629     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7630     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7631     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7632
7633     state = 0xdeadbee;
7634     action = 0xdeadbee;
7635     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7636     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7637     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7638     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7639
7640     state = 0xdeadbee;
7641     action = 0xdeadbee;
7642     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7643     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7644     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7645     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7646
7647     state = 0xdeadbee;
7648     action = 0xdeadbee;
7649     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7650     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7651     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7652     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7653
7654     state = 0xdeadbee;
7655     action = 0xdeadbee;
7656     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7657     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7658     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7659     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7660
7661     state = 0xdeadbee;
7662     action = 0xdeadbee;
7663     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7664     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7665     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7666     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7667
7668     state = 0xdeadbee;
7669     action = 0xdeadbee;
7670     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7671     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7672     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7673     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7674
7675     MsiCloseHandle(hpkg);
7676
7677     /* uninstall the product */
7678     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7680
7681     DeleteFileA(msifile);
7682     DeleteFileA(msifile2);
7683     DeleteFileA(msifile3);
7684     DeleteFileA(msifile4);
7685 }
7686
7687 static void test_getproperty(void)
7688 {
7689     MSIHANDLE hPackage = 0;
7690     char prop[100];
7691     static CHAR empty[] = "";
7692     DWORD size;
7693     UINT r;
7694
7695     r = package_from_db(create_package_db(), &hPackage);
7696     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7697     {
7698         skip("Not enough rights to perform tests\n");
7699         DeleteFile(msifile);
7700         return;
7701     }
7702     ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
7703
7704     /* set the property */
7705     r = MsiSetProperty(hPackage, "Name", "Value");
7706     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7707
7708     /* retrieve the size, NULL pointer */
7709     size = 0;
7710     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7712     ok( size == 5, "Expected 5, got %d\n", size);
7713
7714     /* retrieve the size, empty string */
7715     size = 0;
7716     r = MsiGetProperty(hPackage, "Name", empty, &size);
7717     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7718     ok( size == 5, "Expected 5, got %d\n", size);
7719
7720     /* don't change size */
7721     r = MsiGetProperty(hPackage, "Name", prop, &size);
7722     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7723     ok( size == 5, "Expected 5, got %d\n", size);
7724     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7725
7726     /* increase the size by 1 */
7727     size++;
7728     r = MsiGetProperty(hPackage, "Name", prop, &size);
7729     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7730     ok( size == 5, "Expected 5, got %d\n", size);
7731     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7732
7733     r = MsiCloseHandle( hPackage);
7734     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7735     DeleteFile(msifile);
7736 }
7737
7738 static void test_removefiles(void)
7739 {
7740     MSIHANDLE hpkg;
7741     UINT r;
7742     MSIHANDLE hdb;
7743     INSTALLSTATE installed, action;
7744
7745     hdb = create_package_db();
7746     ok ( hdb, "failed to create package database\n" );
7747
7748     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7749     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7750
7751     r = create_feature_table( hdb );
7752     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7753
7754     r = create_component_table( hdb );
7755     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7756
7757     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7758     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7759
7760     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7761     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7762
7763     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7764     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7765
7766     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7767     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7768
7769     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7770     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7771
7772     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7773     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7774
7775     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7776     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7777
7778     r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
7779     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7780
7781     r = create_feature_components_table( hdb );
7782     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7783
7784     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7785     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7786
7787     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7788     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7789
7790     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7791     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7792
7793     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7794     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7795
7796     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7797     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7798
7799     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7800     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7801
7802     r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
7803     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7804
7805     r = create_file_table( hdb );
7806     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7807
7808     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7809     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7810
7811     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7812     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7813
7814     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7815     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7816
7817     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7818     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7819
7820     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7821     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7822
7823     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7824     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7825
7826     r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
7827     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7828
7829     r = create_remove_file_table( hdb );
7830     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7831
7832     r = package_from_db( hdb, &hpkg );
7833     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7834     {
7835         skip("Not enough rights to perform tests\n");
7836         DeleteFile(msifile);
7837         return;
7838     }
7839     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7840
7841     MsiCloseHandle( hdb );
7842
7843     create_test_file( "hydrogen.txt" );
7844     create_test_file( "helium.txt" );
7845     create_test_file( "lithium.txt" );
7846     create_test_file( "beryllium.txt" );
7847     create_test_file( "boron.txt" );
7848     create_test_file( "carbon.txt" );
7849     create_test_file( "oxygen.txt" );
7850
7851     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7852     ok( r == ERROR_SUCCESS, "set property failed\n");
7853
7854     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7855
7856     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7857     ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
7858
7859     r = MsiDoAction( hpkg, "CostInitialize");
7860     ok( r == ERROR_SUCCESS, "cost init failed\n");
7861
7862     r = MsiDoAction( hpkg, "FileCost");
7863     ok( r == ERROR_SUCCESS, "file cost failed\n");
7864
7865     installed = action = 0xdeadbeef;
7866     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7867     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7868     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7869     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7870
7871     r = MsiDoAction( hpkg, "CostFinalize");
7872     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7873
7874     r = MsiDoAction( hpkg, "InstallValidate");
7875     ok( r == ERROR_SUCCESS, "install validate failed\n");
7876
7877     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7878     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7879
7880     installed = action = 0xdeadbeef;
7881     r = MsiGetComponentState( hpkg, "hydrogen", &installed, &action );
7882     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7883     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7884     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7885
7886     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7887     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7888
7889     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7890     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7891
7892     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7893     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7894
7895     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7896     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7897
7898     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7899     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7900
7901     installed = action = 0xdeadbeef;
7902     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7903     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7904     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7905     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7906
7907     r = MsiSetComponentState( hpkg, "oxygen", INSTALLSTATE_ABSENT );
7908     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7909
7910     installed = action = 0xdeadbeef;
7911     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7912     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7913     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7914     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7915
7916     r = MsiDoAction( hpkg, "RemoveFiles");
7917     ok( r == ERROR_SUCCESS, "remove files failed\n");
7918
7919     installed = action = 0xdeadbeef;
7920     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7921     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7922     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7923     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7924
7925     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7926     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7927     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7928     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7929     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7930     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7931     ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
7932
7933     MsiCloseHandle( hpkg );
7934     DeleteFileA(msifile);
7935 }
7936
7937 static void test_appsearch(void)
7938 {
7939     MSIHANDLE hpkg;
7940     UINT r;
7941     MSIHANDLE hdb;
7942     CHAR prop[MAX_PATH];
7943     DWORD size;
7944
7945     hdb = create_package_db();
7946     ok ( hdb, "failed to create package database\n" );
7947
7948     r = create_appsearch_table( hdb );
7949     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7950
7951     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7952     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7953
7954     r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
7955     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7956
7957     r = create_reglocator_table( hdb );
7958     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7959
7960     r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
7961     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7962
7963     r = create_drlocator_table( hdb );
7964     ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
7965
7966     r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
7967     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7968
7969     r = create_signature_table( hdb );
7970     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7971
7972     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7973     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7974
7975     r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
7976     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7977
7978     r = package_from_db( hdb, &hpkg );
7979     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7980     {
7981         skip("Not enough rights to perform tests\n");
7982         DeleteFile(msifile);
7983         return;
7984     }
7985     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7986     MsiCloseHandle( hdb );
7987     if (r != ERROR_SUCCESS)
7988         goto done;
7989
7990     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7991
7992     r = MsiDoAction( hpkg, "AppSearch" );
7993     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7994
7995     size = sizeof(prop);
7996     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7997     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7998     ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7999
8000     size = sizeof(prop);
8001     r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
8002     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
8003
8004 done:
8005     MsiCloseHandle( hpkg );
8006     DeleteFileA(msifile);
8007 }
8008
8009 static void test_appsearch_complocator(void)
8010 {
8011     MSIHANDLE hpkg, hdb;
8012     CHAR path[MAX_PATH];
8013     CHAR prop[MAX_PATH];
8014     LPSTR usersid;
8015     DWORD size;
8016     UINT r;
8017
8018     if (!(usersid = get_user_sid()))
8019         return;
8020
8021     if (is_process_limited())
8022     {
8023         skip("process is limited\n");
8024         return;
8025     }
8026
8027     create_test_file("FileName1");
8028     create_test_file("FileName4");
8029     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
8030                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
8031
8032     create_test_file("FileName2");
8033     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
8034                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
8035
8036     create_test_file("FileName3");
8037     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
8038                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
8039
8040     create_test_file("FileName5");
8041     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
8042                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
8043
8044     create_test_file("FileName6");
8045     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
8046                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
8047
8048     create_test_file("FileName7");
8049     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
8050                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
8051
8052     /* dir is FALSE, but we're pretending it's a directory */
8053     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
8054                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
8055
8056     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8057     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
8058                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
8059
8060     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8061     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
8062                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
8063
8064     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8065     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
8066                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
8067
8068     hdb = create_package_db();
8069     ok(hdb, "Expected a valid database handle\n");
8070
8071     r = create_appsearch_table(hdb);
8072     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8073
8074     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8075     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8076
8077     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8078     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8079
8080     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8081     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8082
8083     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8085
8086     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8087     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8088
8089     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8090     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8091
8092     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8094
8095     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8096     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8097
8098     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8100
8101     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8102     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8103
8104     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8106
8107     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8108     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8109
8110     r = create_complocator_table(hdb);
8111     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8112
8113     /* published component, machine, file, signature, misdbLocatorTypeFile */
8114     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
8115     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8116
8117     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
8118     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
8119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8120
8121     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
8122     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
8123     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8124
8125     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
8126     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
8127     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8128
8129     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
8130     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
8131     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8132
8133     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
8134     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
8135     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8136
8137     /* published component, machine, file, no signature, misdbLocatorTypeFile */
8138     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
8139     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8140
8141     /* unpublished component, no signature, misdbLocatorTypeDir */
8142     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
8143     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8144
8145     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
8146     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
8147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8148
8149     /* published component, signature w/ ver, misdbLocatorTypeFile */
8150     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
8151     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8152
8153     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
8154     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
8155     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8156
8157     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
8158     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
8159     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8160
8161     r = create_signature_table(hdb);
8162     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8163
8164     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
8165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8166
8167     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
8168     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8169
8170     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
8171     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172
8173     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
8174     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8175
8176     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
8177     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8178
8179     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8180     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8181
8182     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8183     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8184
8185     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8186     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8187
8188     r = package_from_db(hdb, &hpkg);
8189     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8190     {
8191         skip("Not enough rights to perform tests\n");
8192         goto error;
8193     }
8194     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8195
8196     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
8197     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8198
8199     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8200
8201     r = MsiDoAction(hpkg, "AppSearch");
8202     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8203
8204     size = MAX_PATH;
8205     sprintf(path, "%s\\FileName1", CURR_DIR);
8206     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8207     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8208     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8209
8210     size = MAX_PATH;
8211     sprintf(path, "%s\\FileName2", CURR_DIR);
8212     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8214     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8215
8216     size = MAX_PATH;
8217     sprintf(path, "%s\\FileName3", CURR_DIR);
8218     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8219     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8220     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8221
8222     size = MAX_PATH;
8223     sprintf(path, "%s\\FileName4", CURR_DIR);
8224     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8225     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8226     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8227
8228     size = MAX_PATH;
8229     sprintf(path, "%s\\FileName5", CURR_DIR);
8230     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8231     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8232     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8233
8234     size = MAX_PATH;
8235     sprintf(path, "%s\\", CURR_DIR);
8236     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8237     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8238     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8239
8240     size = MAX_PATH;
8241     sprintf(path, "%s\\", CURR_DIR);
8242     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8243     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8244     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8245
8246     size = MAX_PATH;
8247     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8248     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8249     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
8250
8251     size = MAX_PATH;
8252     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8253     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8254     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8255
8256     size = MAX_PATH;
8257     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
8258     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8259     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8260     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8261
8262     size = MAX_PATH;
8263     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8264     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8265     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8266
8267     size = MAX_PATH;
8268     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
8269     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8270     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8271     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8272
8273     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
8274                           MSIINSTALLCONTEXT_MACHINE, NULL);
8275     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
8276                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
8277     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
8278                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
8279     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
8280                           MSIINSTALLCONTEXT_MACHINE, NULL);
8281     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
8282                           MSIINSTALLCONTEXT_MACHINE, NULL);
8283     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
8284                           MSIINSTALLCONTEXT_MACHINE, NULL);
8285     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
8286                           MSIINSTALLCONTEXT_MACHINE, NULL);
8287     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
8288                           MSIINSTALLCONTEXT_MACHINE, NULL);
8289     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
8290                           MSIINSTALLCONTEXT_MACHINE, NULL);
8291     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
8292                           MSIINSTALLCONTEXT_MACHINE, NULL);
8293
8294     MsiCloseHandle(hpkg);
8295
8296 error:
8297     DeleteFileA("FileName1");
8298     DeleteFileA("FileName2");
8299     DeleteFileA("FileName3");
8300     DeleteFileA("FileName4");
8301     DeleteFileA("FileName5");
8302     DeleteFileA("FileName6");
8303     DeleteFileA("FileName7");
8304     DeleteFileA("FileName8.dll");
8305     DeleteFileA("FileName9.dll");
8306     DeleteFileA("FileName10.dll");
8307     DeleteFileA(msifile);
8308     LocalFree(usersid);
8309 }
8310
8311 static void test_appsearch_reglocator(void)
8312 {
8313     MSIHANDLE hpkg, hdb;
8314     CHAR path[MAX_PATH], prop[MAX_PATH];
8315     DWORD binary[2], size, val;
8316     BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
8317     HKEY hklm, classes, hkcu, users;
8318     LPSTR pathdata, pathvar, ptr;
8319     LPCSTR str;
8320     LONG res;
8321     UINT r, type = 0;
8322     SYSTEM_INFO si;
8323
8324     version = TRUE;
8325     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8326         version = FALSE;
8327
8328     DeleteFileA("test.dll");
8329
8330     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
8331     if (res == ERROR_ACCESS_DENIED)
8332     {
8333         skip("Not enough rights to perform tests\n");
8334         return;
8335     }
8336     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8337
8338     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
8339                          (const BYTE *)"regszdata", 10);
8340     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8341
8342     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
8343     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8344
8345     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
8346                          (const BYTE *)"regszdata", 10);
8347     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8348
8349     users = 0;
8350     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
8351     ok(res == ERROR_SUCCESS ||
8352        broken(res == ERROR_INVALID_PARAMETER),
8353        "Expected ERROR_SUCCESS, got %d\n", res);
8354
8355     if (res == ERROR_SUCCESS)
8356     {
8357         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
8358                              (const BYTE *)"regszdata", 10);
8359         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8360     }
8361
8362     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
8363     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8364
8365     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
8366     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8367
8368     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
8369                          (const BYTE *)"regszdata", 10);
8370     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8371
8372     val = 42;
8373     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
8374                          (const BYTE *)&val, sizeof(DWORD));
8375     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8376
8377     val = -42;
8378     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
8379                          (const BYTE *)&val, sizeof(DWORD));
8380     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8381
8382     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
8383                          (const BYTE *)"%PATH%", 7);
8384     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8385
8386     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
8387                          (const BYTE *)"my%NOVAR%", 10);
8388     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8389
8390     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
8391                          (const BYTE *)"one\0two\0", 9);
8392     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8393
8394     binary[0] = 0x1234abcd;
8395     binary[1] = 0x567890ef;
8396     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
8397                          (const BYTE *)binary, sizeof(binary));
8398     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8399
8400     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
8401                          (const BYTE *)"#regszdata", 11);
8402     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8403
8404     create_test_file("FileName1");
8405     sprintf(path, "%s\\FileName1", CURR_DIR);
8406     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
8407                          (const BYTE *)path, lstrlenA(path) + 1);
8408     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8409
8410     sprintf(path, "%s\\FileName2", CURR_DIR);
8411     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
8412                          (const BYTE *)path, lstrlenA(path) + 1);
8413     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8414
8415     lstrcpyA(path, CURR_DIR);
8416     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
8417                          (const BYTE *)path, lstrlenA(path) + 1);
8418     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8419
8420     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
8421                          (const BYTE *)"", 1);
8422     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8423
8424     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8425     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8426     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
8427                          (const BYTE *)path, lstrlenA(path) + 1);
8428     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8429
8430     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8431     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8432     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
8433                          (const BYTE *)path, lstrlenA(path) + 1);
8434     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8435
8436     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8437     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8438     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
8439                          (const BYTE *)path, lstrlenA(path) + 1);
8440     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8441
8442     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
8443     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
8444                          (const BYTE *)path, lstrlenA(path) + 1);
8445     ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", res);
8446
8447     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
8448     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
8449     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
8450                          (const BYTE *)path, lstrlenA(path) + 1);
8451     ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", res);
8452
8453     hdb = create_package_db();
8454     ok(hdb, "Expected a valid database handle\n");
8455
8456     r = create_appsearch_table(hdb);
8457     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8458
8459     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8460     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8461
8462     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8463     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8464
8465     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8467
8468     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8469     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8470
8471     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8472     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8473
8474     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8476
8477     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8478     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8479
8480     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8481     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8482
8483     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8485
8486     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8487     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8488
8489     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8490     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8491
8492     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8493     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8494
8495     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8496     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8497
8498     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
8499     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8500
8501     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
8502     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8503
8504     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
8505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8506
8507     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
8508     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8509
8510     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
8511     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8512
8513     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
8514     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8515
8516     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
8517     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8518
8519     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
8520     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8521
8522     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
8523     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8524
8525     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
8526     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8527
8528     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
8529     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8530
8531     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
8532     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8533
8534     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
8535     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8536
8537     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
8538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8539
8540     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
8541     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8542
8543     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
8544     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8545
8546     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
8547     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8548
8549     r = create_reglocator_table(hdb);
8550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8551
8552     type = msidbLocatorTypeRawValue;
8553     if (is_64bit)
8554         type |= msidbLocatorType64bit;
8555
8556     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
8557     r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
8558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8559
8560     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
8561     r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
8562     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8563
8564     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
8565     r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
8566     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8567
8568     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8569     r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
8570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8571
8572     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8573     r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
8574     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8575
8576     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
8577     r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
8578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8579
8580     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
8581     r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
8582     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8583
8584     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
8585     r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
8586     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8587
8588     type = msidbLocatorTypeFileName;
8589     if (is_64bit)
8590         type |= msidbLocatorType64bit;
8591
8592     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
8593     r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
8594     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8595
8596     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
8597     r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
8598     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8599
8600     /* HKLM, msidbLocatorTypeFileName, no signature */
8601     r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
8602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8603
8604     type = msidbLocatorTypeDirectory;
8605     if (is_64bit)
8606         type |= msidbLocatorType64bit;
8607
8608     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
8609     r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
8610     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8611
8612     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
8613     r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
8614     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8615
8616     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
8617     r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
8618     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8619
8620     type = msidbLocatorTypeRawValue;
8621     if (is_64bit)
8622         type |= msidbLocatorType64bit;
8623
8624     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
8625     r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
8626     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8627
8628     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
8629     r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
8630     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8631
8632     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
8633     r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
8634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8635
8636     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
8637     r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
8638     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8639
8640     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
8641     r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
8642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8643
8644     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
8645     r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
8646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8647
8648     type = msidbLocatorTypeFileName;
8649     if (is_64bit)
8650         type |= msidbLocatorType64bit;
8651
8652     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
8653     r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
8654     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8655
8656     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
8657     r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
8658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8659
8660     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
8661     r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
8662     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8663
8664     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
8665     r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
8666     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8667
8668     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
8669     r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
8670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8671
8672     type = msidbLocatorTypeDirectory;
8673     if (is_64bit)
8674         type |= msidbLocatorType64bit;
8675
8676     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8677     r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
8678     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8679
8680     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8681     r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
8682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8683
8684     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8685     r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
8686     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8687
8688     type = msidbLocatorTypeFileName;
8689     if (is_64bit)
8690         type |= msidbLocatorType64bit;
8691
8692     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8693     r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
8694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8695
8696     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8697     r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
8698     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8699
8700     r = create_signature_table(hdb);
8701     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8702
8703     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8704     r = add_signature_entry(hdb, str);
8705     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8706
8707     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8708     r = add_signature_entry(hdb, str);
8709     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8710
8711     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8712     r = add_signature_entry(hdb, str);
8713     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8714
8715     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8716     r = add_signature_entry(hdb, str);
8717     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8718
8719     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8720     r = add_signature_entry(hdb, str);
8721     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8722
8723     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8724     r = add_signature_entry(hdb, str);
8725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8726
8727     ptr = strrchr(CURR_DIR, '\\') + 1;
8728     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8729     r = add_signature_entry(hdb, path);
8730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8731
8732     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8733     r = add_signature_entry(hdb, str);
8734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8735
8736     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8737     r = add_signature_entry(hdb, str);
8738     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8739
8740     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8741     r = add_signature_entry(hdb, str);
8742     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8743
8744     r = package_from_db(hdb, &hpkg);
8745     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8746
8747     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8748
8749     r = MsiDoAction(hpkg, "AppSearch");
8750     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8751
8752     size = MAX_PATH;
8753     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8755     ok(!lstrcmpA(prop, "regszdata"),
8756        "Expected \"regszdata\", got \"%s\"\n", prop);
8757
8758     size = MAX_PATH;
8759     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8760     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8761     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8762
8763     size = MAX_PATH;
8764     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8765     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8766     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8767
8768     memset(&si, 0, sizeof(si));
8769     if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
8770
8771     if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
8772     {
8773         size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8774         pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8775         ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8776
8777         size = 0;
8778         r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8779         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8780
8781         pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8782         r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8783         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8784         ok(!lstrcmpA(pathdata, pathvar),
8785             "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8786
8787         HeapFree(GetProcessHeap(), 0, pathvar);
8788         HeapFree(GetProcessHeap(), 0, pathdata);
8789     }
8790
8791     size = MAX_PATH;
8792     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8793     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8794     ok(!lstrcmpA(prop,
8795        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8796
8797     size = MAX_PATH;
8798     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8799     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8800     todo_wine
8801     {
8802         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8803            "Expected \"\\0one\\0two\\0\\0\"\n");
8804     }
8805
8806     size = MAX_PATH;
8807     lstrcpyA(path, "#xCDAB3412EF907856");
8808     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8809     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8810     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8811
8812     size = MAX_PATH;
8813     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8815     ok(!lstrcmpA(prop, "##regszdata"),
8816        "Expected \"##regszdata\", got \"%s\"\n", prop);
8817
8818     size = MAX_PATH;
8819     sprintf(path, "%s\\FileName1", CURR_DIR);
8820     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8821     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8822     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8823
8824     size = MAX_PATH;
8825     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8826     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8827     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8828
8829     size = MAX_PATH;
8830     sprintf(path, "%s\\", CURR_DIR);
8831     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8832     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8833     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8834
8835     size = MAX_PATH;
8836     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8838     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8839
8840     size = MAX_PATH;
8841     sprintf(path, "%s\\", CURR_DIR);
8842     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
8843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8844     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8845
8846     size = MAX_PATH;
8847     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
8848     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8849     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8850
8851     size = MAX_PATH;
8852     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8853     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8854     ok(!lstrcmpA(prop, "regszdata"),
8855        "Expected \"regszdata\", got \"%s\"\n", prop);
8856
8857     size = MAX_PATH;
8858     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8859     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8860     ok(!lstrcmpA(prop, "regszdata"),
8861        "Expected \"regszdata\", got \"%s\"\n", prop);
8862
8863     if (users)
8864     {
8865         size = MAX_PATH;
8866         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8867         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8868         ok(!lstrcmpA(prop, "regszdata"),
8869            "Expected \"regszdata\", got \"%s\"\n", prop);
8870     }
8871
8872     size = MAX_PATH;
8873     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8874     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8875     ok(!lstrcmpA(prop, "defvalue"),
8876        "Expected \"defvalue\", got \"%s\"\n", prop);
8877
8878     size = MAX_PATH;
8879     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8880     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8881     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8882
8883     size = MAX_PATH;
8884     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
8885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8886     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8887
8888     if (version)
8889     {
8890         size = MAX_PATH;
8891         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8892         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8893         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8894         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8895
8896         size = MAX_PATH;
8897         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8898         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8899         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8900
8901         size = MAX_PATH;
8902         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8903         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8904         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8905         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8906     }
8907
8908     size = MAX_PATH;
8909     lstrcpyA(path, CURR_DIR);
8910     ptr = strrchr(path, '\\') + 1;
8911     *ptr = '\0';
8912     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8914     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8915
8916     size = MAX_PATH;
8917     sprintf(path, "%s\\", CURR_DIR);
8918     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8919     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8920     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8921
8922     size = MAX_PATH;
8923     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8925     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8926
8927     size = MAX_PATH;
8928     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8930     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8931
8932     size = MAX_PATH;
8933     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8934     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8935     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8936
8937     size = MAX_PATH;
8938     sprintf(path, "%s\\FileName1", CURR_DIR);
8939     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8940     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8941     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8942
8943     size = MAX_PATH;
8944     sprintf(path, "%s\\FileName1", CURR_DIR);
8945     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8946     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8947     if (space)
8948         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8949     else
8950         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8951
8952     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8953     RegDeleteValueA(hklm, "Value1");
8954     RegDeleteValueA(hklm, "Value2");
8955     RegDeleteValueA(hklm, "Value3");
8956     RegDeleteValueA(hklm, "Value4");
8957     RegDeleteValueA(hklm, "Value5");
8958     RegDeleteValueA(hklm, "Value6");
8959     RegDeleteValueA(hklm, "Value7");
8960     RegDeleteValueA(hklm, "Value8");
8961     RegDeleteValueA(hklm, "Value9");
8962     RegDeleteValueA(hklm, "Value10");
8963     RegDeleteValueA(hklm, "Value11");
8964     RegDeleteValueA(hklm, "Value12");
8965     RegDeleteValueA(hklm, "Value13");
8966     RegDeleteValueA(hklm, "Value14");
8967     RegDeleteValueA(hklm, "Value15");
8968     RegDeleteValueA(hklm, "Value16");
8969     RegDeleteValueA(hklm, "Value17");
8970     RegDeleteKey(hklm, "");
8971     RegCloseKey(hklm);
8972
8973     RegDeleteValueA(classes, "Value1");
8974     RegDeleteKeyA(classes, "");
8975     RegCloseKey(classes);
8976
8977     RegDeleteValueA(hkcu, "Value1");
8978     RegDeleteKeyA(hkcu, "");
8979     RegCloseKey(hkcu);
8980
8981     RegDeleteValueA(users, "Value1");
8982     RegDeleteKeyA(users, "");
8983     RegCloseKey(users);
8984
8985     DeleteFileA("FileName1");
8986     DeleteFileA("FileName3.dll");
8987     DeleteFileA("FileName4.dll");
8988     DeleteFileA("FileName5.dll");
8989     MsiCloseHandle(hpkg);
8990     DeleteFileA(msifile);
8991 }
8992
8993 static void delete_win_ini(LPCSTR file)
8994 {
8995     CHAR path[MAX_PATH];
8996
8997     GetWindowsDirectoryA(path, MAX_PATH);
8998     lstrcatA(path, "\\");
8999     lstrcatA(path, file);
9000
9001     DeleteFileA(path);
9002 }
9003
9004 static void test_appsearch_inilocator(void)
9005 {
9006     MSIHANDLE hpkg, hdb;
9007     CHAR path[MAX_PATH];
9008     CHAR prop[MAX_PATH];
9009     BOOL version;
9010     LPCSTR str;
9011     LPSTR ptr;
9012     DWORD size;
9013     UINT r;
9014
9015     version = TRUE;
9016     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
9017         version = FALSE;
9018
9019     DeleteFileA("test.dll");
9020
9021     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
9022
9023     create_test_file("FileName1");
9024     sprintf(path, "%s\\FileName1", CURR_DIR);
9025     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
9026
9027     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
9028
9029     sprintf(path, "%s\\IDontExist", CURR_DIR);
9030     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
9031
9032     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9033     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
9034     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
9035
9036     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
9037     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9038     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
9039
9040     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9041     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
9042     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
9043
9044     hdb = create_package_db();
9045     ok(hdb, "Expected a valid database handle\n");
9046
9047     r = create_appsearch_table(hdb);
9048     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9049
9050     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
9051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9052
9053     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
9054     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9055
9056     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
9057     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9058
9059     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
9060     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9061
9062     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
9063     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9064
9065     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
9066     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9067
9068     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
9069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9070
9071     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
9072     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9073
9074     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
9075     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9076
9077     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
9078     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9079
9080     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
9081     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9082
9083     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
9084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9085
9086     r = create_inilocator_table(hdb);
9087     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9088
9089     /* msidbLocatorTypeRawValue, field 1 */
9090     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
9091     r = add_inilocator_entry(hdb, str);
9092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9093
9094     /* msidbLocatorTypeRawValue, field 2 */
9095     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
9096     r = add_inilocator_entry(hdb, str);
9097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9098
9099     /* msidbLocatorTypeRawValue, entire field */
9100     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
9101     r = add_inilocator_entry(hdb, str);
9102     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9103
9104     /* msidbLocatorTypeFile */
9105     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
9106     r = add_inilocator_entry(hdb, str);
9107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9108
9109     /* msidbLocatorTypeDirectory, file */
9110     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
9111     r = add_inilocator_entry(hdb, str);
9112     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9113
9114     /* msidbLocatorTypeDirectory, directory */
9115     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
9116     r = add_inilocator_entry(hdb, str);
9117     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9118
9119     /* msidbLocatorTypeFile, file, no signature */
9120     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
9121     r = add_inilocator_entry(hdb, str);
9122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9123
9124     /* msidbLocatorTypeFile, dir, no signature */
9125     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
9126     r = add_inilocator_entry(hdb, str);
9127     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9128
9129     /* msidbLocatorTypeFile, file does not exist */
9130     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
9131     r = add_inilocator_entry(hdb, str);
9132     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9133
9134     /* msidbLocatorTypeFile, signature with version */
9135     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
9136     r = add_inilocator_entry(hdb, str);
9137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9138
9139     /* msidbLocatorTypeFile, signature with version, ver > max */
9140     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
9141     r = add_inilocator_entry(hdb, str);
9142     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9143
9144     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
9145     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
9146     r = add_inilocator_entry(hdb, str);
9147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9148
9149     r = create_signature_table(hdb);
9150     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9151
9152     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
9153     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9154
9155     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
9156     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9157
9158     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9159     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9160
9161     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9162     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9163
9164     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9166
9167     r = package_from_db(hdb, &hpkg);
9168     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9169     {
9170         skip("Not enough rights to perform tests\n");
9171         goto error;
9172     }
9173     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9174
9175     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9176
9177     r = MsiDoAction(hpkg, "AppSearch");
9178     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9179
9180     size = MAX_PATH;
9181     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9182     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9183     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
9184
9185     size = MAX_PATH;
9186     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9187     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9188     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
9189
9190     size = MAX_PATH;
9191     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9192     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9193     ok(!lstrcmpA(prop, "keydata,field2"),
9194        "Expected \"keydata,field2\", got \"%s\"\n", prop);
9195
9196     size = MAX_PATH;
9197     sprintf(path, "%s\\FileName1", CURR_DIR);
9198     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9199     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9200     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9201
9202     size = MAX_PATH;
9203     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9204     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9205     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9206
9207     size = MAX_PATH;
9208     sprintf(path, "%s\\", CURR_DIR);
9209     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9210     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9211     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9212
9213     size = MAX_PATH;
9214     sprintf(path, "%s\\", CURR_DIR);
9215     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9216     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9217     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9218
9219     size = MAX_PATH;
9220     lstrcpyA(path, CURR_DIR);
9221     ptr = strrchr(path, '\\');
9222     *(ptr + 1) = '\0';
9223     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9224     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9225     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9226
9227     size = MAX_PATH;
9228     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9229     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9230     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9231
9232     if (version)
9233     {
9234         size = MAX_PATH;
9235         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
9236         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9237         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9238         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9239
9240         size = MAX_PATH;
9241         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9242         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9243         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9244
9245         size = MAX_PATH;
9246         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
9247         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
9248         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9249         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9250     }
9251
9252     MsiCloseHandle(hpkg);
9253
9254 error:
9255     delete_win_ini("IniFile.ini");
9256     DeleteFileA("FileName1");
9257     DeleteFileA("FileName2.dll");
9258     DeleteFileA("FileName3.dll");
9259     DeleteFileA("FileName4.dll");
9260     DeleteFileA(msifile);
9261 }
9262
9263 /*
9264  * MSI AppSearch action on DrLocator table always returns absolute paths.
9265  * If a relative path was set, it returns the first absolute path that
9266  * matches or an empty string if it didn't find anything.
9267  * This helper function replicates this behaviour.
9268  */
9269 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
9270 {
9271     int i, size;
9272     DWORD attr, drives;
9273
9274     size = lstrlenA(relative);
9275     drives = GetLogicalDrives();
9276     lstrcpyA(absolute, "A:\\");
9277     for (i = 0; i < 26; absolute[0] = '\0', i++)
9278     {
9279         if (!(drives & (1 << i)))
9280             continue;
9281
9282         absolute[0] = 'A' + i;
9283         if (GetDriveType(absolute) != DRIVE_FIXED)
9284             continue;
9285
9286         lstrcpynA(absolute + 3, relative, size + 1);
9287         attr = GetFileAttributesA(absolute);
9288         if (attr != INVALID_FILE_ATTRIBUTES &&
9289             (attr & FILE_ATTRIBUTE_DIRECTORY))
9290         {
9291             if (absolute[3 + size - 1] != '\\')
9292                 lstrcatA(absolute, "\\");
9293             break;
9294         }
9295         absolute[3] = '\0';
9296     }
9297 }
9298
9299 static void test_appsearch_drlocator(void)
9300 {
9301     MSIHANDLE hpkg, hdb;
9302     CHAR path[MAX_PATH];
9303     CHAR prop[MAX_PATH];
9304     BOOL version;
9305     LPCSTR str;
9306     DWORD size;
9307     UINT r;
9308
9309     version = TRUE;
9310     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
9311         version = FALSE;
9312
9313     DeleteFileA("test.dll");
9314
9315     create_test_file("FileName1");
9316     CreateDirectoryA("one", NULL);
9317     CreateDirectoryA("one\\two", NULL);
9318     CreateDirectoryA("one\\two\\three", NULL);
9319     create_test_file("one\\two\\three\\FileName2");
9320     CreateDirectoryA("another", NULL);
9321     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9322     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
9323     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9324
9325     hdb = create_package_db();
9326     ok(hdb, "Expected a valid database handle\n");
9327
9328     r = create_appsearch_table(hdb);
9329     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9330
9331     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
9332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9333
9334     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
9335     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9336
9337     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
9338     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9339
9340     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
9341     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9342
9343     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
9344     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9345
9346     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
9347     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9348
9349     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
9350     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9351
9352     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
9353     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9354
9355     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
9356     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9357
9358     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
9359     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9360
9361     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
9362     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9363
9364     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
9365     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9366
9367     r = create_drlocator_table(hdb);
9368     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9369
9370     /* no parent, full path, depth 0, signature */
9371     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
9372     r = add_drlocator_entry(hdb, path);
9373     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9374
9375     /* no parent, full path, depth 0, no signature */
9376     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
9377     r = add_drlocator_entry(hdb, path);
9378     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9379
9380     /* no parent, relative path, depth 0, no signature */
9381     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
9382     r = add_drlocator_entry(hdb, path);
9383     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9384
9385     /* no parent, full path, depth 2, signature */
9386     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
9387     r = add_drlocator_entry(hdb, path);
9388     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9389
9390     /* no parent, full path, depth 3, signature */
9391     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
9392     r = add_drlocator_entry(hdb, path);
9393     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9394
9395     /* no parent, full path, depth 1, signature is dir */
9396     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
9397     r = add_drlocator_entry(hdb, path);
9398     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9399
9400     /* parent is in DrLocator, relative path, depth 0, signature */
9401     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
9402     r = add_drlocator_entry(hdb, path);
9403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9404
9405     /* no parent, full path, depth 0, signature w/ version */
9406     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
9407     r = add_drlocator_entry(hdb, path);
9408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9409
9410     /* no parent, full path, depth 0, signature w/ version, ver > max */
9411     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
9412     r = add_drlocator_entry(hdb, path);
9413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9414
9415     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
9416     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
9417     r = add_drlocator_entry(hdb, path);
9418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9419
9420     /* no parent, relative empty path, depth 0, no signature */
9421     sprintf(path, "'NewSignature11', '', '', 0");
9422     r = add_drlocator_entry(hdb, path);
9423     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9424
9425     r = create_reglocator_table(hdb);
9426     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9427
9428     /* parent */
9429     r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
9430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9431
9432     /* parent is in RegLocator, no path, depth 0, no signature */
9433     sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
9434     r = add_drlocator_entry(hdb, path);
9435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9436
9437     r = create_signature_table(hdb);
9438     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9439
9440     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
9441     r = add_signature_entry(hdb, str);
9442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9443
9444     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
9445     r = add_signature_entry(hdb, str);
9446     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9447
9448     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
9449     r = add_signature_entry(hdb, str);
9450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9451
9452     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
9453     r = add_signature_entry(hdb, str);
9454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9455
9456     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
9457     r = add_signature_entry(hdb, str);
9458     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9459
9460     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9461     r = add_signature_entry(hdb, str);
9462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9463
9464     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9465     r = add_signature_entry(hdb, str);
9466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9467
9468     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9469     r = add_signature_entry(hdb, str);
9470     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9471
9472     r = package_from_db(hdb, &hpkg);
9473     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9474     {
9475         skip("Not enough rights to perform tests\n");
9476         goto error;
9477     }
9478     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9479
9480     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9481
9482     r = MsiDoAction(hpkg, "AppSearch");
9483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9484
9485     size = MAX_PATH;
9486     sprintf(path, "%s\\FileName1", CURR_DIR);
9487     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9488     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9489     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9490
9491     size = MAX_PATH;
9492     sprintf(path, "%s\\", CURR_DIR);
9493     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9494     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9495     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9496
9497     size = MAX_PATH;
9498     search_absolute_directory(path, CURR_DIR + 3);
9499     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9501     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9502
9503     size = MAX_PATH;
9504     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9506     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9507
9508     size = MAX_PATH;
9509     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9510     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9511     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9512     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9513
9514     size = MAX_PATH;
9515     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9517     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9518
9519     size = MAX_PATH;
9520     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9521     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9523     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9524
9525     if (version)
9526     {
9527         size = MAX_PATH;
9528         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9529         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9530         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9531         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9532
9533         size = MAX_PATH;
9534         r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9535         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9536         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9537
9538         size = MAX_PATH;
9539         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9540         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9541         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9542     }
9543
9544     size = MAX_PATH;
9545     search_absolute_directory(path, "");
9546     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9547     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9548     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9549
9550     size = MAX_PATH;
9551     strcpy(path, "c:\\");
9552     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
9553     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9554     ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
9555
9556     MsiCloseHandle(hpkg);
9557
9558 error:
9559     DeleteFileA("FileName1");
9560     DeleteFileA("FileName3.dll");
9561     DeleteFileA("FileName4.dll");
9562     DeleteFileA("FileName5.dll");
9563     DeleteFileA("one\\two\\three\\FileName2");
9564     RemoveDirectoryA("one\\two\\three");
9565     RemoveDirectoryA("one\\two");
9566     RemoveDirectoryA("one");
9567     RemoveDirectoryA("another");
9568     DeleteFileA(msifile);
9569 }
9570
9571 static void test_featureparents(void)
9572 {
9573     MSIHANDLE hpkg;
9574     UINT r;
9575     MSIHANDLE hdb;
9576     INSTALLSTATE state, action;
9577
9578     hdb = create_package_db();
9579     ok ( hdb, "failed to create package database\n" );
9580
9581     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
9582     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
9583
9584     r = create_feature_table( hdb );
9585     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
9586
9587     r = create_component_table( hdb );
9588     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
9589
9590     r = create_feature_components_table( hdb );
9591     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
9592
9593     r = create_file_table( hdb );
9594     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
9595
9596     /* msidbFeatureAttributesFavorLocal */
9597     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
9598     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9599
9600     /* msidbFeatureAttributesFavorSource */
9601     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
9602     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9603
9604     /* msidbFeatureAttributesFavorLocal */
9605     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
9606     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9607
9608     /* msidbFeatureAttributesUIDisallowAbsent */
9609     r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
9610     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9611
9612     /* disabled because of install level */
9613     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
9614     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9615
9616     /* child feature of disabled feature */
9617     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
9618     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9619
9620     /* component of disabled feature (install level) */
9621     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
9622     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9623
9624     /* component of disabled child feature (install level) */
9625     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
9626     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9627
9628     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9629     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
9630     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9631
9632     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9633     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
9634     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9635
9636     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9637     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
9638     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9639
9640     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
9641     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
9642     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9643
9644     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
9645     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
9646     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9647
9648     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
9649     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
9650     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9651
9652     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9653     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
9654     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9655
9656     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9657     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
9658     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9659
9660     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9661     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
9662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
9663
9664     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
9665     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9666
9667     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
9668     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9669
9670     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
9671     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9672
9673     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
9674     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9675
9676     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
9677     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9678
9679     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
9680     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9681
9682     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
9683     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9684
9685     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
9686     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9687
9688     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
9689     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9690
9691     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
9692     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9693
9694     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
9695     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9696
9697     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
9698     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9699
9700     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
9701     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9702
9703     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
9704     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9705
9706     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
9707     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9708
9709     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
9710     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9711
9712     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
9713     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9714
9715     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
9716     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9717
9718     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
9719     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9720
9721     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9722     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9723
9724     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9725     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9726
9727     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9728     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9729
9730     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9731     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9732
9733     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9734     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9735
9736     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9737     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9738
9739     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9740     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9741
9742     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9743     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9744
9745     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9746     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9747
9748     r = package_from_db( hdb, &hpkg );
9749     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9750     {
9751         skip("Not enough rights to perform tests\n");
9752         DeleteFile(msifile);
9753         return;
9754     }
9755     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9756
9757     MsiCloseHandle( hdb );
9758
9759     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9760
9761     r = MsiDoAction( hpkg, "CostInitialize");
9762     ok( r == ERROR_SUCCESS, "cost init failed\n");
9763
9764     r = MsiDoAction( hpkg, "FileCost");
9765     ok( r == ERROR_SUCCESS, "file cost failed\n");
9766
9767     r = MsiDoAction( hpkg, "CostFinalize");
9768     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9769
9770     state = 0xdeadbee;
9771     action = 0xdeadbee;
9772     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9773     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9774     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9775     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9776
9777     state = 0xdeadbee;
9778     action = 0xdeadbee;
9779     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9780     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9781     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9782     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9783
9784     state = 0xdeadbee;
9785     action = 0xdeadbee;
9786     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9787     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9788     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9789     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9790
9791     state = 0xdeadbee;
9792     action = 0xdeadbee;
9793     r = MsiGetFeatureState(hpkg, "lyra", &state, &action);
9794     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9795     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9796     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9797
9798     state = 0xdeadbee;
9799     action = 0xdeadbee;
9800     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9801     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9802     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9803     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9804
9805     state = 0xdeadbee;
9806     action = 0xdeadbee;
9807     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9808     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9809     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9810     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9811
9812     state = 0xdeadbee;
9813     action = 0xdeadbee;
9814     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9815     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9816     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9817     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9818
9819     state = 0xdeadbee;
9820     action = 0xdeadbee;
9821     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9822     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9823     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9824     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9825
9826     state = 0xdeadbee;
9827     action = 0xdeadbee;
9828     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9829     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9830     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9831     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9832
9833     state = 0xdeadbee;
9834     action = 0xdeadbee;
9835     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9836     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9837     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9838     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9839
9840     state = 0xdeadbee;
9841     action = 0xdeadbee;
9842     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9843     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9844     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9845     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9846
9847     state = 0xdeadbee;
9848     action = 0xdeadbee;
9849     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9850     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9851     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9852     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9853
9854     state = 0xdeadbee;
9855     action = 0xdeadbee;
9856     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9857     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9858     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9859     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9860
9861     state = 0xdeadbee;
9862     action = 0xdeadbee;
9863     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9864     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9865     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9866     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9867
9868     state = 0xdeadbee;
9869     action = 0xdeadbee;
9870     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9871     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9872     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9873     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9874
9875     state = 0xdeadbee;
9876     action = 0xdeadbee;
9877     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9878     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9879     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9880     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9881
9882     state = 0xdeadbee;
9883     action = 0xdeadbee;
9884     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9885     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9886     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9887     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9888
9889     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9890     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9891
9892     r = MsiSetFeatureState(hpkg, "lyra", INSTALLSTATE_ABSENT);
9893     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9894
9895     r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
9896     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
9897
9898     state = 0xdeadbee;
9899     action = 0xdeadbee;
9900     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9901     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9902     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9903     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9904
9905     state = 0xdeadbee;
9906     action = 0xdeadbee;
9907     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9908     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9909     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9910     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9911
9912     state = 0xdeadbee;
9913     action = 0xdeadbee;
9914     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9915     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9916     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9917     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9918
9919     state = 0xdeadbee;
9920     action = 0xdeadbee;
9921     r = MsiGetFeatureState(hpkg, "lyra", &state, &action);
9922     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9923     ok( state == INSTALLSTATE_ABSENT, "Expected lyra INSTALLSTATE_ABSENT, got %d\n", state);
9924     ok( action == INSTALLSTATE_ABSENT, "Expected lyra INSTALLSTATE_ABSENT, got %d\n", action);
9925
9926     state = 0xdeadbee;
9927     action = 0xdeadbee;
9928     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9929     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9930     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9931     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9932
9933     state = 0xdeadbee;
9934     action = 0xdeadbee;
9935     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9936     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9937     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9938     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9939
9940     state = 0xdeadbee;
9941     action = 0xdeadbee;
9942     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9943     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9944     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9945     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9946
9947     state = 0xdeadbee;
9948     action = 0xdeadbee;
9949     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9950     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9951     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9952     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9953
9954     state = 0xdeadbee;
9955     action = 0xdeadbee;
9956     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9957     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9958     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9959     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9960
9961     state = 0xdeadbee;
9962     action = 0xdeadbee;
9963     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9964     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9965     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9966     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9967
9968     state = 0xdeadbee;
9969     action = 0xdeadbee;
9970     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9971     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9972     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9973     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9974
9975     state = 0xdeadbee;
9976     action = 0xdeadbee;
9977     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9978     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9979     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9980     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9981
9982     state = 0xdeadbee;
9983     action = 0xdeadbee;
9984     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9985     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9986     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9987     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9988
9989     state = 0xdeadbee;
9990     action = 0xdeadbee;
9991     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9992     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9993     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9994     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9995
9996     state = 0xdeadbee;
9997     action = 0xdeadbee;
9998     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9999     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
10000     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
10001     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
10002     
10003     MsiCloseHandle(hpkg);
10004     DeleteFileA(msifile);
10005 }
10006
10007 static void test_installprops(void)
10008 {
10009     MSIHANDLE hpkg, hdb;
10010     CHAR path[MAX_PATH], buf[MAX_PATH];
10011     DWORD size, type;
10012     LANGID langid;
10013     HKEY hkey1, hkey2;
10014     int res;
10015     UINT r;
10016     REGSAM access = KEY_ALL_ACCESS;
10017     SYSTEM_INFO si;
10018
10019     if (is_wow64)
10020         access |= KEY_WOW64_64KEY;
10021
10022     GetCurrentDirectory(MAX_PATH, path);
10023     lstrcat(path, "\\");
10024     lstrcat(path, msifile);
10025
10026     hdb = create_package_db();
10027     ok( hdb, "failed to create database\n");
10028
10029     r = package_from_db(hdb, &hpkg);
10030     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10031     {
10032         skip("Not enough rights to perform tests\n");
10033         DeleteFile(msifile);
10034         return;
10035     }
10036     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
10037
10038     MsiCloseHandle(hdb);
10039
10040     size = MAX_PATH;
10041     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
10042     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10043     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10044
10045     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
10046     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
10047
10048     size = MAX_PATH;
10049     type = REG_SZ;
10050     *path = '\0';
10051     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
10052     {
10053         size = MAX_PATH;
10054         type = REG_SZ;
10055         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
10056     }
10057
10058     size = MAX_PATH;
10059     r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
10060     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10061     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10062
10063     size = MAX_PATH;
10064     type = REG_SZ;
10065     *path = '\0';
10066     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
10067     {
10068         size = MAX_PATH;
10069         type = REG_SZ;
10070         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
10071     }
10072
10073     if (*path)
10074     {
10075         size = MAX_PATH;
10076         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
10077         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10078         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10079     }
10080
10081     size = MAX_PATH;
10082     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
10083     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10084     trace("VersionDatabase = %s\n", buf);
10085
10086     size = MAX_PATH;
10087     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
10088     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10089     trace("VersionMsi = %s\n", buf);
10090
10091     size = MAX_PATH;
10092     r = MsiGetProperty(hpkg, "Date", buf, &size);
10093     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10094     trace("Date = %s\n", buf);
10095
10096     size = MAX_PATH;
10097     r = MsiGetProperty(hpkg, "Time", buf, &size);
10098     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10099     trace("Time = %s\n", buf);
10100
10101     size = MAX_PATH;
10102     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
10103     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10104     trace("PackageCode = %s\n", buf);
10105
10106     langid = GetUserDefaultLangID();
10107     sprintf(path, "%d", langid);
10108
10109     size = MAX_PATH;
10110     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
10111     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
10112     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
10113
10114     res = GetSystemMetrics(SM_CXSCREEN);
10115     size = MAX_PATH;
10116     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
10117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
10118     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
10119
10120     res = GetSystemMetrics(SM_CYSCREEN);
10121     size = MAX_PATH;
10122     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
10123     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
10124     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
10125
10126     if (pGetSystemInfo && pSHGetFolderPathA)
10127     {
10128         pGetSystemInfo(&si);
10129         if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
10130         {
10131             buf[0] = 0;
10132             size = MAX_PATH;
10133             r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10134             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10135             ok(buf[0], "property not set\n");
10136
10137             buf[0] = 0;
10138             size = MAX_PATH;
10139             r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10140             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10141             ok(buf[0], "property not set\n");
10142
10143             buf[0] = 0;
10144             size = MAX_PATH;
10145             r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10146             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10147             GetSystemDirectoryA(path, MAX_PATH);
10148             if (size) buf[size - 1] = 0;
10149             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10150
10151             buf[0] = 0;
10152             size = MAX_PATH;
10153             r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10154             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10155             pGetSystemWow64DirectoryA(path, MAX_PATH);
10156             if (size) buf[size - 1] = 0;
10157             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10158
10159             buf[0] = 0;
10160             size = MAX_PATH;
10161             r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
10162             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10163             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
10164             if (size) buf[size - 1] = 0;
10165             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10166
10167             buf[0] = 0;
10168             size = MAX_PATH;
10169             r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10170             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10171             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
10172             if (size) buf[size - 1] = 0;
10173             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10174
10175             buf[0] = 0;
10176             size = MAX_PATH;
10177             r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
10178             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10179             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
10180             if (size) buf[size - 1] = 0;
10181             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10182
10183             buf[0] = 0;
10184             size = MAX_PATH;
10185             r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10186             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10187             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
10188             if (size) buf[size - 1] = 0;
10189             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10190
10191             buf[0] = 0;
10192             size = MAX_PATH;
10193             r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10194             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10195             ok(buf[0], "property not set\n");
10196         }
10197         else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
10198         {
10199             if (!is_wow64)
10200             {
10201                 buf[0] = 0;
10202                 size = MAX_PATH;
10203                 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10204                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10205                 ok(!buf[0], "property set\n");
10206
10207                 buf[0] = 0;
10208                 size = MAX_PATH;
10209                 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10210                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10211                 ok(!buf[0], "property set\n");
10212
10213                 buf[0] = 0;
10214                 size = MAX_PATH;
10215                 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10216                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10217                 ok(!buf[0], "property set\n");
10218
10219                 buf[0] = 0;
10220                 size = MAX_PATH;
10221                 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10222                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10223                 GetSystemDirectoryA(path, MAX_PATH);
10224                 if (size) buf[size - 1] = 0;
10225                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10226
10227                 buf[0] = 0;
10228                 size = MAX_PATH;
10229                 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
10230                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10231                 ok(!buf[0], "property set\n");
10232
10233                 buf[0] = 0;
10234                 size = MAX_PATH;
10235                 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10236                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10237                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
10238                 if (size) buf[size - 1] = 0;
10239                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10240
10241                 buf[0] = 0;
10242                 size = MAX_PATH;
10243                 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
10244                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10245                 ok(!buf[0], "property set\n");
10246
10247                 buf[0] = 0;
10248                 size = MAX_PATH;
10249                 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10250                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10251                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
10252                 if (size) buf[size - 1] = 0;
10253                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10254
10255                 buf[0] = 0;
10256                 size = MAX_PATH;
10257                 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10258                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10259                 ok(!buf[0], "property set\n");
10260             }
10261             else
10262             {
10263                 buf[0] = 0;
10264                 size = MAX_PATH;
10265                 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10266                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10267                 ok(buf[0], "property not set\n");
10268
10269                 buf[0] = 0;
10270                 size = MAX_PATH;
10271                 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10272                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10273                 ok(buf[0], "property not set\n");
10274
10275                 buf[0] = 0;
10276                 size = MAX_PATH;
10277                 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10278                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10279                 GetSystemDirectoryA(path, MAX_PATH);
10280                 if (size) buf[size - 1] = 0;
10281                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10282
10283                 buf[0] = 0;
10284                 size = MAX_PATH;
10285                 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10286                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10287                 pGetSystemWow64DirectoryA(path, MAX_PATH);
10288                 if (size) buf[size - 1] = 0;
10289                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10290
10291                 buf[0] = 0;
10292                 size = MAX_PATH;
10293                 r = MsiGetProperty(hpkg, "ProgramFilesFolder64", buf, &size);
10294                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10295                 ok(!buf[0], "property set\n");
10296
10297                 buf[0] = 0;
10298                 size = MAX_PATH;
10299                 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10300                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10301                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
10302                 if (size) buf[size - 1] = 0;
10303                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10304
10305                 buf[0] = 0;
10306                 size = MAX_PATH;
10307                 r = MsiGetProperty(hpkg, "CommonFilesFolder64", buf, &size);
10308                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10309                 ok(!buf[0], "property set\n");
10310
10311                 buf[0] = 0;
10312                 size = MAX_PATH;
10313                 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10314                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10315                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
10316                 if (size) buf[size - 1] = 0;
10317                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10318
10319                 buf[0] = 0;
10320                 size = MAX_PATH;
10321                 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10322                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10323                 ok(buf[0], "property not set\n");
10324             }
10325         }
10326     }
10327
10328     CloseHandle(hkey1);
10329     CloseHandle(hkey2);
10330     MsiCloseHandle(hpkg);
10331     DeleteFile(msifile);
10332 }
10333
10334 static void test_launchconditions(void)
10335 {
10336     MSIHANDLE hpkg;
10337     MSIHANDLE hdb;
10338     UINT r;
10339
10340     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10341
10342     hdb = create_package_db();
10343     ok( hdb, "failed to create package database\n" );
10344
10345     r = create_launchcondition_table( hdb );
10346     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
10347
10348     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
10349     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
10350
10351     /* invalid condition */
10352     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
10353     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
10354
10355     r = package_from_db( hdb, &hpkg );
10356     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10357     {
10358         skip("Not enough rights to perform tests\n");
10359         DeleteFile(msifile);
10360         return;
10361     }
10362     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
10363
10364     MsiCloseHandle( hdb );
10365
10366     r = MsiSetProperty( hpkg, "X", "1" );
10367     ok( r == ERROR_SUCCESS, "failed to set property\n" );
10368
10369     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10370
10371     /* invalid conditions are ignored */
10372     r = MsiDoAction( hpkg, "LaunchConditions" );
10373     ok( r == ERROR_SUCCESS, "cost init failed\n" );
10374
10375     /* verify LaunchConditions still does some verification */
10376     r = MsiSetProperty( hpkg, "X", "2" );
10377     ok( r == ERROR_SUCCESS, "failed to set property\n" );
10378
10379     r = MsiDoAction( hpkg, "LaunchConditions" );
10380     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
10381
10382     MsiCloseHandle( hpkg );
10383     DeleteFile( msifile );
10384 }
10385
10386 static void test_ccpsearch(void)
10387 {
10388     MSIHANDLE hdb, hpkg;
10389     CHAR prop[MAX_PATH];
10390     DWORD size = MAX_PATH;
10391     UINT r;
10392
10393     hdb = create_package_db();
10394     ok(hdb, "failed to create package database\n");
10395
10396     r = create_ccpsearch_table(hdb);
10397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10398
10399     r = add_ccpsearch_entry(hdb, "'CCP_random'");
10400     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10401
10402     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
10403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10404
10405     r = create_reglocator_table(hdb);
10406     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10407
10408     r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
10409     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10410
10411     r = create_drlocator_table(hdb);
10412     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10413
10414     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
10415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10416
10417     r = create_signature_table(hdb);
10418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10419
10420     r = package_from_db(hdb, &hpkg);
10421     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10422     {
10423         skip("Not enough rights to perform tests\n");
10424         DeleteFile(msifile);
10425         return;
10426     }
10427     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10428
10429     MsiCloseHandle(hdb);
10430
10431     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10432
10433     r = MsiDoAction(hpkg, "CCPSearch");
10434     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10435
10436     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
10437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10438     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
10439
10440     MsiCloseHandle(hpkg);
10441     DeleteFileA(msifile);
10442 }
10443
10444 static void test_complocator(void)
10445 {
10446     MSIHANDLE hdb, hpkg;
10447     UINT r;
10448     CHAR prop[MAX_PATH];
10449     CHAR expected[MAX_PATH];
10450     DWORD size = MAX_PATH;
10451
10452     hdb = create_package_db();
10453     ok(hdb, "failed to create package database\n");
10454
10455     r = create_appsearch_table(hdb);
10456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10457
10458     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
10459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10460
10461     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
10462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10463
10464     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
10465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10466
10467     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
10468     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10469
10470     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
10471     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10472
10473     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
10474     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10475
10476     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
10477     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10478
10479     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
10480     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10481
10482     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
10483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10484
10485     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
10486     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10487
10488     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
10489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10490
10491     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
10492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10493
10494     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
10495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10496
10497     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
10498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10499
10500     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
10501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10502
10503     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
10504     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10505
10506     r = create_complocator_table(hdb);
10507     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10508
10509     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
10510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10511
10512     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
10513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10514
10515     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
10516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10517
10518     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
10519     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10520
10521     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
10522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10523
10524     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
10525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10526
10527     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
10528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10529
10530     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
10531     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10532
10533     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
10534     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10535
10536     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
10537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10538
10539     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
10540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10541
10542     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
10543     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10544
10545     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
10546     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10547
10548     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
10549     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10550
10551     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
10552     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10553
10554     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
10555     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10556
10557     r = create_signature_table(hdb);
10558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10559
10560     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
10561     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10562
10563     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
10564     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10565
10566     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
10567     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10568
10569     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
10570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10571
10572     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
10573     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10574
10575     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
10576     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10577
10578     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
10579     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10580
10581     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
10582     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10583
10584     r = package_from_db(hdb, &hpkg);
10585     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10586     {
10587         skip("Not enough rights to perform tests\n");
10588         DeleteFile(msifile);
10589         return;
10590     }
10591     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10592
10593     MsiCloseHandle(hdb);
10594
10595     create_test_file("abelisaurus");
10596     create_test_file("bactrosaurus");
10597     create_test_file("camelotia");
10598     create_test_file("diclonius");
10599     create_test_file("echinodon");
10600     create_test_file("falcarius");
10601     create_test_file("gallimimus");
10602     create_test_file("hagryphus");
10603     CreateDirectoryA("iguanodon", NULL);
10604     CreateDirectoryA("jobaria", NULL);
10605     CreateDirectoryA("kakuru", NULL);
10606     CreateDirectoryA("labocania", NULL);
10607     CreateDirectoryA("megaraptor", NULL);
10608     CreateDirectoryA("neosodon", NULL);
10609     CreateDirectoryA("olorotitan", NULL);
10610     CreateDirectoryA("pantydraco", NULL);
10611
10612     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
10613                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
10614     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
10615                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
10616     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
10617                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
10618     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
10619                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
10620     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
10621                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
10622     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
10623                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
10624     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
10625                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
10626     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
10627                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
10628
10629     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10630
10631     r = MsiDoAction(hpkg, "AppSearch");
10632     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10633
10634     size = MAX_PATH;
10635     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
10636     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10637
10638     lstrcpyA(expected, CURR_DIR);
10639     lstrcatA(expected, "\\abelisaurus");
10640     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10641        "Expected %s or empty string, got %s\n", expected, prop);
10642
10643     size = MAX_PATH;
10644     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
10645     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10646     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10647
10648     size = MAX_PATH;
10649     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
10650     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10651     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10652
10653     size = MAX_PATH;
10654     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
10655     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10656     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10657
10658     size = MAX_PATH;
10659     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
10660     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10661
10662     lstrcpyA(expected, CURR_DIR);
10663     lstrcatA(expected, "\\");
10664     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10665        "Expected %s or empty string, got %s\n", expected, prop);
10666
10667     size = MAX_PATH;
10668     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
10669     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10670     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10671
10672     size = MAX_PATH;
10673     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
10674     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10675     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10676
10677     size = MAX_PATH;
10678     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
10679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10680     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10681
10682     size = MAX_PATH;
10683     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
10684     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10685     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10686
10687     size = MAX_PATH;
10688     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
10689     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10690     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10691
10692     size = MAX_PATH;
10693     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
10694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10695     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10696
10697     size = MAX_PATH;
10698     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
10699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10700     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10701
10702     size = MAX_PATH;
10703     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
10704     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10705
10706     lstrcpyA(expected, CURR_DIR);
10707     lstrcatA(expected, "\\");
10708     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10709        "Expected %s or empty string, got %s\n", expected, prop);
10710
10711     size = MAX_PATH;
10712     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
10713     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10714
10715     lstrcpyA(expected, CURR_DIR);
10716     lstrcatA(expected, "\\neosodon\\");
10717     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10718        "Expected %s or empty string, got %s\n", expected, prop);
10719
10720     size = MAX_PATH;
10721     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
10722     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10723     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10724
10725     size = MAX_PATH;
10726     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
10727     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10728     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10729
10730     MsiCloseHandle(hpkg);
10731     DeleteFileA("abelisaurus");
10732     DeleteFileA("bactrosaurus");
10733     DeleteFileA("camelotia");
10734     DeleteFileA("diclonius");
10735     DeleteFileA("echinodon");
10736     DeleteFileA("falcarius");
10737     DeleteFileA("gallimimus");
10738     DeleteFileA("hagryphus");
10739     RemoveDirectoryA("iguanodon");
10740     RemoveDirectoryA("jobaria");
10741     RemoveDirectoryA("kakuru");
10742     RemoveDirectoryA("labocania");
10743     RemoveDirectoryA("megaraptor");
10744     RemoveDirectoryA("neosodon");
10745     RemoveDirectoryA("olorotitan");
10746     RemoveDirectoryA("pantydraco");
10747     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
10748                           MSIINSTALLCONTEXT_MACHINE, NULL);
10749     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
10750                           MSIINSTALLCONTEXT_MACHINE, NULL);
10751     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
10752                           MSIINSTALLCONTEXT_MACHINE, NULL);
10753     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
10754                           MSIINSTALLCONTEXT_MACHINE, NULL);
10755     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
10756                           MSIINSTALLCONTEXT_MACHINE, NULL);
10757     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
10758                           MSIINSTALLCONTEXT_MACHINE, NULL);
10759     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
10760                           MSIINSTALLCONTEXT_MACHINE, NULL);
10761     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
10762                           MSIINSTALLCONTEXT_MACHINE, NULL);
10763     DeleteFileA(msifile);
10764 }
10765
10766 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
10767 {
10768     MSIHANDLE summary;
10769     UINT r;
10770
10771     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
10772     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10773
10774     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
10775     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10776
10777     r = MsiSummaryInfoPersist(summary);
10778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10779
10780     MsiCloseHandle(summary);
10781 }
10782
10783 static void test_MsiGetSourcePath(void)
10784 {
10785     MSIHANDLE hdb, hpkg;
10786     CHAR path[MAX_PATH];
10787     CHAR cwd[MAX_PATH];
10788     CHAR subsrc[MAX_PATH];
10789     CHAR sub2[MAX_PATH];
10790     DWORD size;
10791     UINT r;
10792
10793     lstrcpyA(cwd, CURR_DIR);
10794     lstrcatA(cwd, "\\");
10795
10796     lstrcpyA(subsrc, cwd);
10797     lstrcatA(subsrc, "subsource");
10798     lstrcatA(subsrc, "\\");
10799
10800     lstrcpyA(sub2, subsrc);
10801     lstrcatA(sub2, "sub2");
10802     lstrcatA(sub2, "\\");
10803
10804     /* uncompressed source */
10805
10806     hdb = create_package_db();
10807     ok( hdb, "failed to create database\n");
10808
10809     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10810
10811     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10812     ok(r == S_OK, "failed\n");
10813
10814     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
10815     ok(r == S_OK, "failed\n");
10816
10817     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
10818     ok(r == S_OK, "failed\n");
10819
10820     r = MsiDatabaseCommit(hdb);
10821     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
10822
10823     r = package_from_db(hdb, &hpkg);
10824     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10825     {
10826         skip("Not enough rights to perform tests\n");
10827         DeleteFile(msifile);
10828         return;
10829     }
10830     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10831
10832     MsiCloseHandle(hdb);
10833
10834     /* invalid database handle */
10835     size = MAX_PATH;
10836     lstrcpyA(path, "kiwi");
10837     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
10838     ok(r == ERROR_INVALID_HANDLE,
10839        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
10840     ok(!lstrcmpA(path, "kiwi"),
10841        "Expected path to be unchanged, got \"%s\"\n", path);
10842     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10843
10844     /* NULL szFolder */
10845     size = MAX_PATH;
10846     lstrcpyA(path, "kiwi");
10847     r = MsiGetSourcePath(hpkg, NULL, path, &size);
10848     ok(r == ERROR_INVALID_PARAMETER,
10849        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10850     ok(!lstrcmpA(path, "kiwi"),
10851        "Expected path to be unchanged, got \"%s\"\n", path);
10852     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10853
10854     /* empty szFolder */
10855     size = MAX_PATH;
10856     lstrcpyA(path, "kiwi");
10857     r = MsiGetSourcePath(hpkg, "", path, &size);
10858     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10859     ok(!lstrcmpA(path, "kiwi"),
10860        "Expected path to be unchanged, got \"%s\"\n", path);
10861     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10862
10863     /* try TARGETDIR */
10864     size = MAX_PATH;
10865     lstrcpyA(path, "kiwi");
10866     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10867     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10868     ok(!lstrcmpA(path, "kiwi"),
10869        "Expected path to be unchanged, got \"%s\"\n", path);
10870     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10871
10872     size = MAX_PATH;
10873     lstrcpyA(path, "kiwi");
10874     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10875     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10876     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10877     ok(size == 0, "Expected 0, got %d\n", size);
10878
10879     size = MAX_PATH;
10880     lstrcpyA(path, "kiwi");
10881     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10882     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10883     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10884     ok(size == 0, "Expected 0, got %d\n", size);
10885
10886     /* try SourceDir */
10887     size = MAX_PATH;
10888     lstrcpyA(path, "kiwi");
10889     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10890     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10891     ok(!lstrcmpA(path, "kiwi"),
10892        "Expected path to be unchanged, got \"%s\"\n", path);
10893     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10894
10895     /* try SOURCEDIR */
10896     size = MAX_PATH;
10897     lstrcpyA(path, "kiwi");
10898     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10899     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10900     ok(!lstrcmpA(path, "kiwi"),
10901        "Expected path to be unchanged, got \"%s\"\n", path);
10902     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10903
10904     /* source path does not exist, but the property exists */
10905     size = MAX_PATH;
10906     lstrcpyA(path, "kiwi");
10907     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10908     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10909     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10910     ok(size == 0, "Expected 0, got %d\n", size);
10911
10912     size = MAX_PATH;
10913     lstrcpyA(path, "kiwi");
10914     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10916     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10917     ok(size == 0, "Expected 0, got %d\n", size);
10918
10919     /* try SubDir */
10920     size = MAX_PATH;
10921     lstrcpyA(path, "kiwi");
10922     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10923     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10924     ok(!lstrcmpA(path, "kiwi"),
10925        "Expected path to be unchanged, got \"%s\"\n", path);
10926     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10927
10928     /* try SubDir2 */
10929     size = MAX_PATH;
10930     lstrcpyA(path, "kiwi");
10931     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10932     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10933     ok(!lstrcmpA(path, "kiwi"),
10934        "Expected path to be unchanged, got \"%s\"\n", path);
10935     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10936
10937     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10938
10939     r = MsiDoAction(hpkg, "CostInitialize");
10940     ok(r == ERROR_SUCCESS, "cost init failed\n");
10941
10942     /* try TARGETDIR after CostInitialize */
10943     size = MAX_PATH;
10944     lstrcpyA(path, "kiwi");
10945     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10946     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10947     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10948     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10949
10950     /* try SourceDir after CostInitialize */
10951     size = MAX_PATH;
10952     lstrcpyA(path, "kiwi");
10953     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10954     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10955     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10956     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10957
10958     /* try SOURCEDIR after CostInitialize */
10959     size = MAX_PATH;
10960     lstrcpyA(path, "kiwi");
10961     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10962     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10963     ok(!lstrcmpA(path, "kiwi"),
10964        "Expected path to be unchanged, got \"%s\"\n", path);
10965     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10966
10967     /* source path does not exist, but the property exists */
10968     size = MAX_PATH;
10969     lstrcpyA(path, "kiwi");
10970     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10971     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10972     todo_wine
10973     {
10974         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10975         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10976     }
10977
10978     /* try SubDir after CostInitialize */
10979     size = MAX_PATH;
10980     lstrcpyA(path, "kiwi");
10981     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10982     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10983     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10984     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10985
10986     /* try SubDir2 after CostInitialize */
10987     size = MAX_PATH;
10988     lstrcpyA(path, "kiwi");
10989     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10990     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10991     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10992     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10993
10994     r = MsiDoAction(hpkg, "ResolveSource");
10995     ok(r == ERROR_SUCCESS, "file cost failed\n");
10996
10997     /* try TARGETDIR after ResolveSource */
10998     size = MAX_PATH;
10999     lstrcpyA(path, "kiwi");
11000     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11001     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11002     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11003     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11004
11005     /* try SourceDir after ResolveSource */
11006     size = MAX_PATH;
11007     lstrcpyA(path, "kiwi");
11008     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11010     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11011     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11012
11013     /* try SOURCEDIR after ResolveSource */
11014     size = MAX_PATH;
11015     lstrcpyA(path, "kiwi");
11016     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11017     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11018     ok(!lstrcmpA(path, "kiwi"),
11019        "Expected path to be unchanged, got \"%s\"\n", path);
11020     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11021
11022     /* source path does not exist, but the property exists */
11023     size = MAX_PATH;
11024     lstrcpyA(path, "kiwi");
11025     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11026     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11027     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11028     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11029
11030     /* try SubDir after ResolveSource */
11031     size = MAX_PATH;
11032     lstrcpyA(path, "kiwi");
11033     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11034     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11035     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11036     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11037
11038     /* try SubDir2 after ResolveSource */
11039     size = MAX_PATH;
11040     lstrcpyA(path, "kiwi");
11041     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11042     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11043     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11044     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11045
11046     r = MsiDoAction(hpkg, "FileCost");
11047     ok(r == ERROR_SUCCESS, "file cost failed\n");
11048
11049     /* try TARGETDIR after FileCost */
11050     size = MAX_PATH;
11051     lstrcpyA(path, "kiwi");
11052     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11054     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11055     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11056
11057     /* try SourceDir after FileCost */
11058     size = MAX_PATH;
11059     lstrcpyA(path, "kiwi");
11060     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11061     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11062     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11063     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11064
11065     /* try SOURCEDIR after FileCost */
11066     size = MAX_PATH;
11067     lstrcpyA(path, "kiwi");
11068     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11069     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11070     ok(!lstrcmpA(path, "kiwi"),
11071        "Expected path to be unchanged, got \"%s\"\n", path);
11072     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11073
11074     /* source path does not exist, but the property exists */
11075     size = MAX_PATH;
11076     lstrcpyA(path, "kiwi");
11077     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11078     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11079     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11080     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11081
11082     /* try SubDir after FileCost */
11083     size = MAX_PATH;
11084     lstrcpyA(path, "kiwi");
11085     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11086     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11087     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11088     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11089
11090     /* try SubDir2 after FileCost */
11091     size = MAX_PATH;
11092     lstrcpyA(path, "kiwi");
11093     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11094     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11095     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11096     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11097
11098     r = MsiDoAction(hpkg, "CostFinalize");
11099     ok(r == ERROR_SUCCESS, "file cost failed\n");
11100
11101     /* try TARGETDIR after CostFinalize */
11102     size = MAX_PATH;
11103     lstrcpyA(path, "kiwi");
11104     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11106     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11107     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11108
11109     /* try SourceDir after CostFinalize */
11110     size = MAX_PATH;
11111     lstrcpyA(path, "kiwi");
11112     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11113     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11114     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11115     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11116
11117     /* try SOURCEDIR after CostFinalize */
11118     size = MAX_PATH;
11119     lstrcpyA(path, "kiwi");
11120     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11121     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11122     ok(!lstrcmpA(path, "kiwi"),
11123        "Expected path to be unchanged, got \"%s\"\n", path);
11124     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11125
11126     /* source path does not exist, but the property exists */
11127     size = MAX_PATH;
11128     lstrcpyA(path, "kiwi");
11129     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11130     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11131     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11132     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11133
11134     /* try SubDir after CostFinalize */
11135     size = MAX_PATH;
11136     lstrcpyA(path, "kiwi");
11137     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11138     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11139     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11140     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11141
11142     /* try SubDir2 after CostFinalize */
11143     size = MAX_PATH;
11144     lstrcpyA(path, "kiwi");
11145     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11146     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11147     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11148     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11149
11150     /* nonexistent directory */
11151     size = MAX_PATH;
11152     lstrcpyA(path, "kiwi");
11153     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
11154     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11155     ok(!lstrcmpA(path, "kiwi"),
11156        "Expected path to be unchanged, got \"%s\"\n", path);
11157     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11158
11159     /* NULL szPathBuf */
11160     size = MAX_PATH;
11161     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
11162     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11163     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11164
11165     /* NULL pcchPathBuf */
11166     lstrcpyA(path, "kiwi");
11167     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
11168     ok(r == ERROR_INVALID_PARAMETER,
11169        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11170     ok(!lstrcmpA(path, "kiwi"),
11171        "Expected path to be unchanged, got \"%s\"\n", path);
11172
11173     /* pcchPathBuf is 0 */
11174     size = 0;
11175     lstrcpyA(path, "kiwi");
11176     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11177     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11178     ok(!lstrcmpA(path, "kiwi"),
11179        "Expected path to be unchanged, got \"%s\"\n", path);
11180     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11181
11182     /* pcchPathBuf does not have room for NULL terminator */
11183     size = lstrlenA(cwd);
11184     lstrcpyA(path, "kiwi");
11185     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11186     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11187     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
11188        "Expected path with no backslash, got \"%s\"\n", path);
11189     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11190
11191     /* pcchPathBuf has room for NULL terminator */
11192     size = lstrlenA(cwd) + 1;
11193     lstrcpyA(path, "kiwi");
11194     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11195     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11196     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11197     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11198
11199     /* remove property */
11200     r = MsiSetProperty(hpkg, "SourceDir", NULL);
11201     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11202
11203     /* try SourceDir again */
11204     size = MAX_PATH;
11205     lstrcpyA(path, "kiwi");
11206     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11207     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11208     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11209     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11210
11211     /* set property to a valid directory */
11212     r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
11213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11214
11215     /* try SOURCEDIR again */
11216     size = MAX_PATH;
11217     lstrcpyA(path, "kiwi");
11218     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11219     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11220     ok(!lstrcmpA(path, "kiwi"),
11221        "Expected path to be unchanged, got \"%s\"\n", path);
11222     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11223
11224     MsiCloseHandle(hpkg);
11225
11226     /* compressed source */
11227
11228     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11229     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11230
11231     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
11232
11233     r = package_from_db(hdb, &hpkg);
11234     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11235
11236     /* try TARGETDIR */
11237     size = MAX_PATH;
11238     lstrcpyA(path, "kiwi");
11239     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11240     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11241     ok(!lstrcmpA(path, "kiwi"),
11242        "Expected path to be unchanged, got \"%s\"\n", path);
11243     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11244
11245     /* try SourceDir */
11246     size = MAX_PATH;
11247     lstrcpyA(path, "kiwi");
11248     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11249     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11250     ok(!lstrcmpA(path, "kiwi"),
11251        "Expected path to be unchanged, got \"%s\"\n", path);
11252     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11253
11254     /* try SOURCEDIR */
11255     size = MAX_PATH;
11256     lstrcpyA(path, "kiwi");
11257     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11258     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11259     ok(!lstrcmpA(path, "kiwi"),
11260        "Expected path to be unchanged, got \"%s\"\n", path);
11261     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11262
11263     /* source path nor the property exist */
11264     size = MAX_PATH;
11265     lstrcpyA(path, "kiwi");
11266     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11267     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11268     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11269     ok(size == 0, "Expected 0, got %d\n", size);
11270
11271     /* try SubDir */
11272     size = MAX_PATH;
11273     lstrcpyA(path, "kiwi");
11274     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11275     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11276     ok(!lstrcmpA(path, "kiwi"),
11277        "Expected path to be unchanged, got \"%s\"\n", path);
11278     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11279
11280     /* try SubDir2 */
11281     size = MAX_PATH;
11282     lstrcpyA(path, "kiwi");
11283     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11284     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11285     ok(!lstrcmpA(path, "kiwi"),
11286        "Expected path to be unchanged, got \"%s\"\n", path);
11287     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11288
11289     r = MsiDoAction(hpkg, "CostInitialize");
11290     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11291
11292     /* try TARGETDIR after CostInitialize */
11293     size = MAX_PATH;
11294     lstrcpyA(path, "kiwi");
11295     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11296     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11297     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11298     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11299
11300     /* try SourceDir after CostInitialize */
11301     size = MAX_PATH;
11302     lstrcpyA(path, "kiwi");
11303     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11304     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11305     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11306     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11307
11308     /* try SOURCEDIR after CostInitialize */
11309     size = MAX_PATH;
11310     lstrcpyA(path, "kiwi");
11311     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11312     todo_wine
11313     {
11314         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11315         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11316         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11317     }
11318
11319     /* source path does not exist, but the property exists */
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     todo_wine
11325     {
11326         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11327         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11328     }
11329
11330     /* try SubDir after CostInitialize */
11331     size = MAX_PATH;
11332     lstrcpyA(path, "kiwi");
11333     r = MsiGetSourcePath(hpkg, "SubDir", 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     /* try SubDir2 after CostInitialize */
11339     size = MAX_PATH;
11340     lstrcpyA(path, "kiwi");
11341     r = MsiGetSourcePath(hpkg, "SubDir2", 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     r = MsiDoAction(hpkg, "ResolveSource");
11347     ok(r == ERROR_SUCCESS, "file cost failed\n");
11348
11349     /* try TARGETDIR after ResolveSource */
11350     size = MAX_PATH;
11351     lstrcpyA(path, "kiwi");
11352     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11353     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11354     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11355     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11356
11357     /* try SourceDir after ResolveSource */
11358     size = MAX_PATH;
11359     lstrcpyA(path, "kiwi");
11360     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11361     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11362     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11363     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11364
11365     /* try SOURCEDIR after ResolveSource */
11366     size = MAX_PATH;
11367     lstrcpyA(path, "kiwi");
11368     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11369     todo_wine
11370     {
11371         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11372         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11373         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11374     }
11375
11376     /* source path and the property exist */
11377     size = MAX_PATH;
11378     lstrcpyA(path, "kiwi");
11379     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11380     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11381     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11382     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11383
11384     /* try SubDir after ResolveSource */
11385     size = MAX_PATH;
11386     lstrcpyA(path, "kiwi");
11387     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11388     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11389     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11390     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11391
11392     /* try SubDir2 after ResolveSource */
11393     size = MAX_PATH;
11394     lstrcpyA(path, "kiwi");
11395     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11396     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11397     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11398     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11399
11400     r = MsiDoAction(hpkg, "FileCost");
11401     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11402
11403     /* try TARGETDIR after CostFinalize */
11404     size = MAX_PATH;
11405     lstrcpyA(path, "kiwi");
11406     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11408     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11409     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11410
11411     /* try SourceDir after CostFinalize */
11412     size = MAX_PATH;
11413     lstrcpyA(path, "kiwi");
11414     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11416     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11417     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11418
11419     /* try SOURCEDIR after CostFinalize */
11420     size = MAX_PATH;
11421     lstrcpyA(path, "kiwi");
11422     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11423     todo_wine
11424     {
11425         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11426         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11427         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11428     }
11429
11430     /* source path and the property exist */
11431     size = MAX_PATH;
11432     lstrcpyA(path, "kiwi");
11433     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11434     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11435     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11436     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11437
11438     /* try SubDir after CostFinalize */
11439     size = MAX_PATH;
11440     lstrcpyA(path, "kiwi");
11441     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11443     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11444     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11445
11446     /* try SubDir2 after CostFinalize */
11447     size = MAX_PATH;
11448     lstrcpyA(path, "kiwi");
11449     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11451     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11452     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11453
11454     r = MsiDoAction(hpkg, "CostFinalize");
11455     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11456
11457     /* try TARGETDIR after CostFinalize */
11458     size = MAX_PATH;
11459     lstrcpyA(path, "kiwi");
11460     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11461     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11462     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11463     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11464
11465     /* try SourceDir after CostFinalize */
11466     size = MAX_PATH;
11467     lstrcpyA(path, "kiwi");
11468     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11469     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11470     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11471     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11472
11473     /* try SOURCEDIR after CostFinalize */
11474     size = MAX_PATH;
11475     lstrcpyA(path, "kiwi");
11476     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11477     todo_wine
11478     {
11479         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11480         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11481         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11482     }
11483
11484     /* source path and the property exist */
11485     size = MAX_PATH;
11486     lstrcpyA(path, "kiwi");
11487     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11488     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11489     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11490     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11491
11492     /* try SubDir after CostFinalize */
11493     size = MAX_PATH;
11494     lstrcpyA(path, "kiwi");
11495     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11496     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11497     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11498     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11499
11500     /* try SubDir2 after CostFinalize */
11501     size = MAX_PATH;
11502     lstrcpyA(path, "kiwi");
11503     r = MsiGetSourcePath(hpkg, "SubDir2", 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     MsiCloseHandle(hpkg);
11509     DeleteFile(msifile);
11510 }
11511
11512 static void test_shortlongsource(void)
11513 {
11514     MSIHANDLE hdb, hpkg;
11515     CHAR path[MAX_PATH];
11516     CHAR cwd[MAX_PATH];
11517     CHAR subsrc[MAX_PATH];
11518     DWORD size;
11519     UINT r;
11520
11521     lstrcpyA(cwd, CURR_DIR);
11522     lstrcatA(cwd, "\\");
11523
11524     lstrcpyA(subsrc, cwd);
11525     lstrcatA(subsrc, "long");
11526     lstrcatA(subsrc, "\\");
11527
11528     /* long file names */
11529
11530     hdb = create_package_db();
11531     ok( hdb, "failed to create database\n");
11532
11533     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
11534
11535     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11536     ok(r == S_OK, "failed\n");
11537
11538     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
11539     ok(r == S_OK, "failed\n");
11540
11541     /* CostInitialize:short */
11542     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
11543     ok(r == S_OK, "failed\n");
11544
11545     /* CostInitialize:long */
11546     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
11547     ok(r == S_OK, "failed\n");
11548
11549     /* FileCost:short */
11550     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
11551     ok(r == S_OK, "failed\n");
11552
11553     /* FileCost:long */
11554     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
11555     ok(r == S_OK, "failed\n");
11556
11557     /* CostFinalize:short */
11558     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
11559     ok(r == S_OK, "failed\n");
11560
11561     /* CostFinalize:long */
11562     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
11563     ok(r == S_OK, "failed\n");
11564
11565     MsiDatabaseCommit(hdb);
11566
11567     r = package_from_db(hdb, &hpkg);
11568     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11569     {
11570         skip("Not enough rights to perform tests\n");
11571         DeleteFile(msifile);
11572         return;
11573     }
11574     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11575
11576     MsiCloseHandle(hdb);
11577
11578     CreateDirectoryA("one", NULL);
11579     CreateDirectoryA("four", NULL);
11580
11581     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
11582
11583     r = MsiDoAction(hpkg, "CostInitialize");
11584     ok(r == ERROR_SUCCESS, "file cost failed\n");
11585
11586     CreateDirectory("five", NULL);
11587     CreateDirectory("eight", NULL);
11588
11589     r = MsiDoAction(hpkg, "FileCost");
11590     ok(r == ERROR_SUCCESS, "file cost failed\n");
11591
11592     CreateDirectory("nine", NULL);
11593     CreateDirectory("twelve", NULL);
11594
11595     r = MsiDoAction(hpkg, "CostFinalize");
11596     ok(r == ERROR_SUCCESS, "file cost failed\n");
11597
11598     /* neither short nor long source directories exist */
11599     size = MAX_PATH;
11600     lstrcpyA(path, "kiwi");
11601     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11603     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11604     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11605
11606     CreateDirectoryA("short", NULL);
11607
11608     /* short source directory exists */
11609     size = MAX_PATH;
11610     lstrcpyA(path, "kiwi");
11611     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11612     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11613     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11614     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11615
11616     CreateDirectoryA("long", NULL);
11617
11618     /* both short and long source directories exist */
11619     size = MAX_PATH;
11620     lstrcpyA(path, "kiwi");
11621     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11622     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11623     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11624     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11625
11626     lstrcpyA(subsrc, cwd);
11627     lstrcatA(subsrc, "two");
11628     lstrcatA(subsrc, "\\");
11629
11630     /* short dir exists before CostInitialize */
11631     size = MAX_PATH;
11632     lstrcpyA(path, "kiwi");
11633     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11635     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11636     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11637
11638     lstrcpyA(subsrc, cwd);
11639     lstrcatA(subsrc, "four");
11640     lstrcatA(subsrc, "\\");
11641
11642     /* long dir exists before CostInitialize */
11643     size = MAX_PATH;
11644     lstrcpyA(path, "kiwi");
11645     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11647     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11648     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11649
11650     lstrcpyA(subsrc, cwd);
11651     lstrcatA(subsrc, "six");
11652     lstrcatA(subsrc, "\\");
11653
11654     /* short dir exists before FileCost */
11655     size = MAX_PATH;
11656     lstrcpyA(path, "kiwi");
11657     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11659     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11660     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11661
11662     lstrcpyA(subsrc, cwd);
11663     lstrcatA(subsrc, "eight");
11664     lstrcatA(subsrc, "\\");
11665
11666     /* long dir exists before FileCost */
11667     size = MAX_PATH;
11668     lstrcpyA(path, "kiwi");
11669     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11671     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11672     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11673
11674     lstrcpyA(subsrc, cwd);
11675     lstrcatA(subsrc, "ten");
11676     lstrcatA(subsrc, "\\");
11677
11678     /* short dir exists before CostFinalize */
11679     size = MAX_PATH;
11680     lstrcpyA(path, "kiwi");
11681     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11682     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11683     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11684     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11685
11686     lstrcpyA(subsrc, cwd);
11687     lstrcatA(subsrc, "twelve");
11688     lstrcatA(subsrc, "\\");
11689
11690     /* long dir exists before CostFinalize */
11691     size = MAX_PATH;
11692     lstrcpyA(path, "kiwi");
11693     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11695     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11696     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11697
11698     MsiCloseHandle(hpkg);
11699     RemoveDirectoryA("short");
11700     RemoveDirectoryA("long");
11701     RemoveDirectoryA("one");
11702     RemoveDirectoryA("four");
11703     RemoveDirectoryA("five");
11704     RemoveDirectoryA("eight");
11705     RemoveDirectoryA("nine");
11706     RemoveDirectoryA("twelve");
11707
11708     /* short file names */
11709
11710     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11711     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11712
11713     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
11714
11715     r = package_from_db(hdb, &hpkg);
11716     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11717
11718     MsiCloseHandle(hdb);
11719
11720     CreateDirectoryA("one", NULL);
11721     CreateDirectoryA("four", NULL);
11722
11723     r = MsiDoAction(hpkg, "CostInitialize");
11724     ok(r == ERROR_SUCCESS, "file cost failed\n");
11725
11726     CreateDirectory("five", NULL);
11727     CreateDirectory("eight", NULL);
11728
11729     r = MsiDoAction(hpkg, "FileCost");
11730     ok(r == ERROR_SUCCESS, "file cost failed\n");
11731
11732     CreateDirectory("nine", NULL);
11733     CreateDirectory("twelve", NULL);
11734
11735     r = MsiDoAction(hpkg, "CostFinalize");
11736     ok(r == ERROR_SUCCESS, "file cost failed\n");
11737
11738     lstrcpyA(subsrc, cwd);
11739     lstrcatA(subsrc, "short");
11740     lstrcatA(subsrc, "\\");
11741
11742     /* neither short nor long source directories exist */
11743     size = MAX_PATH;
11744     lstrcpyA(path, "kiwi");
11745     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11746     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11747     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11748     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11749
11750     CreateDirectoryA("short", NULL);
11751
11752     /* short source directory exists */
11753     size = MAX_PATH;
11754     lstrcpyA(path, "kiwi");
11755     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11756     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11757     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11758     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11759
11760     CreateDirectoryA("long", NULL);
11761
11762     /* both short and long source directories exist */
11763     size = MAX_PATH;
11764     lstrcpyA(path, "kiwi");
11765     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11767     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11768     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11769
11770     lstrcpyA(subsrc, cwd);
11771     lstrcatA(subsrc, "one");
11772     lstrcatA(subsrc, "\\");
11773
11774     /* short dir exists before CostInitialize */
11775     size = MAX_PATH;
11776     lstrcpyA(path, "kiwi");
11777     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11779     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11780     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11781
11782     lstrcpyA(subsrc, cwd);
11783     lstrcatA(subsrc, "three");
11784     lstrcatA(subsrc, "\\");
11785
11786     /* long dir exists before CostInitialize */
11787     size = MAX_PATH;
11788     lstrcpyA(path, "kiwi");
11789     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11791     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11792     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11793
11794     lstrcpyA(subsrc, cwd);
11795     lstrcatA(subsrc, "five");
11796     lstrcatA(subsrc, "\\");
11797
11798     /* short dir exists before FileCost */
11799     size = MAX_PATH;
11800     lstrcpyA(path, "kiwi");
11801     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11802     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11803     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11804     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11805
11806     lstrcpyA(subsrc, cwd);
11807     lstrcatA(subsrc, "seven");
11808     lstrcatA(subsrc, "\\");
11809
11810     /* long dir exists before FileCost */
11811     size = MAX_PATH;
11812     lstrcpyA(path, "kiwi");
11813     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11815     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11816     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11817
11818     lstrcpyA(subsrc, cwd);
11819     lstrcatA(subsrc, "nine");
11820     lstrcatA(subsrc, "\\");
11821
11822     /* short dir exists before CostFinalize */
11823     size = MAX_PATH;
11824     lstrcpyA(path, "kiwi");
11825     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11826     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11827     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11828     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11829
11830     lstrcpyA(subsrc, cwd);
11831     lstrcatA(subsrc, "eleven");
11832     lstrcatA(subsrc, "\\");
11833
11834     /* long dir exists before CostFinalize */
11835     size = MAX_PATH;
11836     lstrcpyA(path, "kiwi");
11837     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11838     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11839     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11840     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11841
11842     MsiCloseHandle(hpkg);
11843     RemoveDirectoryA("short");
11844     RemoveDirectoryA("long");
11845     RemoveDirectoryA("one");
11846     RemoveDirectoryA("four");
11847     RemoveDirectoryA("five");
11848     RemoveDirectoryA("eight");
11849     RemoveDirectoryA("nine");
11850     RemoveDirectoryA("twelve");
11851     DeleteFileA(msifile);
11852 }
11853
11854 static void test_sourcedir(void)
11855 {
11856     MSIHANDLE hdb, hpkg;
11857     CHAR package[12];
11858     CHAR path[MAX_PATH];
11859     CHAR cwd[MAX_PATH];
11860     CHAR subsrc[MAX_PATH];
11861     DWORD size;
11862     UINT r;
11863
11864     lstrcpyA(cwd, CURR_DIR);
11865     lstrcatA(cwd, "\\");
11866
11867     lstrcpyA(subsrc, cwd);
11868     lstrcatA(subsrc, "long");
11869     lstrcatA(subsrc, "\\");
11870
11871     hdb = create_package_db();
11872     ok( hdb, "failed to create database\n");
11873
11874     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11875     ok(r == S_OK, "failed\n");
11876
11877     sprintf(package, "#%u", hdb);
11878     r = MsiOpenPackage(package, &hpkg);
11879     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11880     {
11881         skip("Not enough rights to perform tests\n");
11882         goto error;
11883     }
11884     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11885
11886     /* properties only */
11887
11888     /* SourceDir prop */
11889     size = MAX_PATH;
11890     lstrcpyA(path, "kiwi");
11891     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11892     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11893     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11894     ok(size == 0, "Expected 0, got %d\n", size);
11895
11896     /* SOURCEDIR prop */
11897     size = MAX_PATH;
11898     lstrcpyA(path, "kiwi");
11899     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11901     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11902     ok(size == 0, "Expected 0, got %d\n", size);
11903
11904     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
11905
11906     r = MsiDoAction(hpkg, "CostInitialize");
11907     ok(r == ERROR_SUCCESS, "file cost failed\n");
11908
11909     /* SourceDir after CostInitialize */
11910     size = MAX_PATH;
11911     lstrcpyA(path, "kiwi");
11912     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11914     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11915     ok(size == 0, "Expected 0, got %d\n", size);
11916
11917     /* SOURCEDIR after CostInitialize */
11918     size = MAX_PATH;
11919     lstrcpyA(path, "kiwi");
11920     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11921     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11922     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11923     ok(size == 0, "Expected 0, got %d\n", size);
11924
11925     r = MsiDoAction(hpkg, "FileCost");
11926     ok(r == ERROR_SUCCESS, "file cost failed\n");
11927
11928     /* SourceDir after FileCost */
11929     size = MAX_PATH;
11930     lstrcpyA(path, "kiwi");
11931     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11932     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11933     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11934     ok(size == 0, "Expected 0, got %d\n", size);
11935
11936     /* SOURCEDIR after FileCost */
11937     size = MAX_PATH;
11938     lstrcpyA(path, "kiwi");
11939     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11940     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11941     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11942     ok(size == 0, "Expected 0, got %d\n", size);
11943
11944     r = MsiDoAction(hpkg, "CostFinalize");
11945     ok(r == ERROR_SUCCESS, "file cost failed\n");
11946
11947     /* SourceDir after CostFinalize */
11948     size = MAX_PATH;
11949     lstrcpyA(path, "kiwi");
11950     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11951     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11952     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11953     ok(size == 0, "Expected 0, got %d\n", size);
11954
11955     /* SOURCEDIR after CostFinalize */
11956     size = MAX_PATH;
11957     lstrcpyA(path, "kiwi");
11958     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11959     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11960     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11961     ok(size == 0, "Expected 0, got %d\n", size);
11962
11963     size = MAX_PATH;
11964     lstrcpyA(path, "kiwi");
11965     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11966     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11967     ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
11968     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
11969
11970     /* SOURCEDIR after calling MsiGetSourcePath */
11971     size = MAX_PATH;
11972     lstrcpyA(path, "kiwi");
11973     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11974     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11975     todo_wine {
11976     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11977     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11978     }
11979
11980     r = MsiDoAction(hpkg, "ResolveSource");
11981     ok(r == ERROR_SUCCESS, "file cost failed\n");
11982
11983     /* SourceDir after ResolveSource */
11984     size = MAX_PATH;
11985     lstrcpyA(path, "kiwi");
11986     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11987     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11988     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11989     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11990
11991     /* SOURCEDIR after ResolveSource */
11992     size = MAX_PATH;
11993     lstrcpyA(path, "kiwi");
11994     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11995     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11996     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11997     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11998
11999     /* random casing */
12000     size = MAX_PATH;
12001     lstrcpyA(path, "kiwi");
12002     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
12003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12004     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12005     ok(size == 0, "Expected 0, got %d\n", size);
12006
12007     MsiCloseHandle(hpkg);
12008
12009     /* reset the package state */
12010     sprintf(package, "#%i", hdb);
12011     r = MsiOpenPackage(package, &hpkg);
12012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12013
12014     /* test how MsiGetSourcePath affects the properties */
12015
12016     /* SourceDir prop */
12017     size = MAX_PATH;
12018     lstrcpyA(path, "kiwi");
12019     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12020     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12021     todo_wine
12022     {
12023         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12024         ok(size == 0, "Expected 0, got %d\n", size);
12025     }
12026
12027     size = MAX_PATH;
12028     lstrcpyA(path, "kiwi");
12029     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
12030     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12031     ok(!lstrcmpA(path, "kiwi"),
12032        "Expected path to be unchanged, got \"%s\"\n", path);
12033     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12034
12035     /* SourceDir after MsiGetSourcePath */
12036     size = MAX_PATH;
12037     lstrcpyA(path, "kiwi");
12038     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12039     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12040     todo_wine
12041     {
12042         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12043         ok(size == 0, "Expected 0, got %d\n", size);
12044     }
12045
12046     /* SOURCEDIR prop */
12047     size = MAX_PATH;
12048     lstrcpyA(path, "kiwi");
12049     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12050     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12051     todo_wine
12052     {
12053         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12054         ok(size == 0, "Expected 0, got %d\n", size);
12055     }
12056
12057     size = MAX_PATH;
12058     lstrcpyA(path, "kiwi");
12059     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12060     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12061     ok(!lstrcmpA(path, "kiwi"),
12062        "Expected path to be unchanged, got \"%s\"\n", path);
12063     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12064
12065     /* SOURCEDIR prop after MsiGetSourcePath */
12066     size = MAX_PATH;
12067     lstrcpyA(path, "kiwi");
12068     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12070     todo_wine
12071     {
12072         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12073         ok(size == 0, "Expected 0, got %d\n", size);
12074     }
12075
12076     r = MsiDoAction(hpkg, "CostInitialize");
12077     ok(r == ERROR_SUCCESS, "file cost failed\n");
12078
12079     /* SourceDir after CostInitialize */
12080     size = MAX_PATH;
12081     lstrcpyA(path, "kiwi");
12082     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12083     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12084     todo_wine
12085     {
12086         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12087         ok(size == 0, "Expected 0, got %d\n", size);
12088     }
12089
12090     size = MAX_PATH;
12091     lstrcpyA(path, "kiwi");
12092     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
12093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12094     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12095     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12096
12097     /* SourceDir after MsiGetSourcePath */
12098     size = MAX_PATH;
12099     lstrcpyA(path, "kiwi");
12100     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12101     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12102     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12103     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12104
12105     /* SOURCEDIR after CostInitialize */
12106     size = MAX_PATH;
12107     lstrcpyA(path, "kiwi");
12108     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12109     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12110     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12111     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12112
12113     /* SOURCEDIR source path still does not exist */
12114     size = MAX_PATH;
12115     lstrcpyA(path, "kiwi");
12116     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12117     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12118     ok(!lstrcmpA(path, "kiwi"),
12119        "Expected path to be unchanged, got \"%s\"\n", path);
12120     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12121
12122     r = MsiDoAction(hpkg, "FileCost");
12123     ok(r == ERROR_SUCCESS, "file cost failed\n");
12124
12125     /* SourceDir after FileCost */
12126     size = MAX_PATH;
12127     lstrcpyA(path, "kiwi");
12128     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12130     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12131     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12132
12133     /* SOURCEDIR after FileCost */
12134     size = MAX_PATH;
12135     lstrcpyA(path, "kiwi");
12136     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12138     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12139     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12140
12141     /* SOURCEDIR source path still does not exist */
12142     size = MAX_PATH;
12143     lstrcpyA(path, "kiwi");
12144     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12145     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12146     ok(!lstrcmpA(path, "kiwi"),
12147        "Expected path to be unchanged, got \"%s\"\n", path);
12148     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12149
12150     r = MsiDoAction(hpkg, "CostFinalize");
12151     ok(r == ERROR_SUCCESS, "file cost failed\n");
12152
12153     /* SourceDir after CostFinalize */
12154     size = MAX_PATH;
12155     lstrcpyA(path, "kiwi");
12156     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12157     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12158     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12159     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12160
12161     /* SOURCEDIR after CostFinalize */
12162     size = MAX_PATH;
12163     lstrcpyA(path, "kiwi");
12164     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12166     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12167     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12168
12169     /* SOURCEDIR source path still does not exist */
12170     size = MAX_PATH;
12171     lstrcpyA(path, "kiwi");
12172     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12173     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12174     ok(!lstrcmpA(path, "kiwi"),
12175        "Expected path to be unchanged, got \"%s\"\n", path);
12176     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12177
12178     r = MsiDoAction(hpkg, "ResolveSource");
12179     ok(r == ERROR_SUCCESS, "file cost failed\n");
12180
12181     /* SourceDir after ResolveSource */
12182     size = MAX_PATH;
12183     lstrcpyA(path, "kiwi");
12184     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12185     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12186     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12187     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12188
12189     /* SOURCEDIR after ResolveSource */
12190     size = MAX_PATH;
12191     lstrcpyA(path, "kiwi");
12192     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12193     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12194     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12195     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12196
12197     /* SOURCEDIR source path still does not exist */
12198     size = MAX_PATH;
12199     lstrcpyA(path, "kiwi");
12200     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12201     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12202     ok(!lstrcmpA(path, "kiwi"),
12203        "Expected path to be unchanged, got \"%s\"\n", path);
12204     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12205
12206     MsiCloseHandle(hpkg);
12207
12208 error:
12209     MsiCloseHandle(hdb);
12210     DeleteFileA(msifile);
12211 }
12212
12213 struct access_res
12214 {
12215     BOOL gothandle;
12216     DWORD lasterr;
12217     BOOL ignore;
12218 };
12219
12220 static const struct access_res create[16] =
12221 {
12222     { TRUE, ERROR_SUCCESS, TRUE },
12223     { TRUE, ERROR_SUCCESS, TRUE },
12224     { TRUE, ERROR_SUCCESS, FALSE },
12225     { TRUE, ERROR_SUCCESS, FALSE },
12226     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12227     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12228     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12229     { TRUE, ERROR_SUCCESS, FALSE },
12230     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12231     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12232     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12233     { TRUE, ERROR_SUCCESS, TRUE },
12234     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12235     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12236     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12237     { TRUE, ERROR_SUCCESS, TRUE }
12238 };
12239
12240 static const struct access_res create_commit[16] =
12241 {
12242     { TRUE, ERROR_SUCCESS, TRUE },
12243     { TRUE, ERROR_SUCCESS, TRUE },
12244     { TRUE, ERROR_SUCCESS, FALSE },
12245     { TRUE, ERROR_SUCCESS, FALSE },
12246     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12247     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12248     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12249     { TRUE, ERROR_SUCCESS, FALSE },
12250     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12251     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12252     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12253     { TRUE, ERROR_SUCCESS, TRUE },
12254     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12255     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12256     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12257     { TRUE, ERROR_SUCCESS, TRUE }
12258 };
12259
12260 static const struct access_res create_close[16] =
12261 {
12262     { TRUE, ERROR_SUCCESS, FALSE },
12263     { TRUE, ERROR_SUCCESS, FALSE },
12264     { TRUE, ERROR_SUCCESS, FALSE },
12265     { TRUE, ERROR_SUCCESS, FALSE },
12266     { TRUE, ERROR_SUCCESS, FALSE },
12267     { TRUE, ERROR_SUCCESS, FALSE },
12268     { TRUE, ERROR_SUCCESS, FALSE },
12269     { TRUE, ERROR_SUCCESS, FALSE },
12270     { TRUE, ERROR_SUCCESS, FALSE },
12271     { TRUE, ERROR_SUCCESS, FALSE },
12272     { TRUE, ERROR_SUCCESS, FALSE },
12273     { TRUE, ERROR_SUCCESS, FALSE },
12274     { TRUE, ERROR_SUCCESS, FALSE },
12275     { TRUE, ERROR_SUCCESS, FALSE },
12276     { TRUE, ERROR_SUCCESS, FALSE },
12277     { TRUE, ERROR_SUCCESS }
12278 };
12279
12280 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
12281 {
12282     DWORD access = 0, share = 0;
12283     DWORD lasterr;
12284     HANDLE hfile;
12285     int i, j, idx = 0;
12286
12287     for (i = 0; i < 4; i++)
12288     {
12289         if (i == 0) access = 0;
12290         if (i == 1) access = GENERIC_READ;
12291         if (i == 2) access = GENERIC_WRITE;
12292         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
12293
12294         for (j = 0; j < 4; j++)
12295         {
12296             if (ares[idx].ignore)
12297                 continue;
12298
12299             if (j == 0) share = 0;
12300             if (j == 1) share = FILE_SHARE_READ;
12301             if (j == 2) share = FILE_SHARE_WRITE;
12302             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
12303
12304             SetLastError(0xdeadbeef);
12305             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
12306                                 FILE_ATTRIBUTE_NORMAL, 0);
12307             lasterr = GetLastError();
12308
12309             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
12310                "(%d, handle, %d): Expected %d, got %d\n",
12311                line, idx, ares[idx].gothandle,
12312                (hfile != INVALID_HANDLE_VALUE));
12313
12314             ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
12315                line, idx, ares[idx].lasterr, lasterr);
12316
12317             CloseHandle(hfile);
12318             idx++;
12319         }
12320     }
12321 }
12322
12323 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
12324
12325 static void test_access(void)
12326 {
12327     MSIHANDLE hdb;
12328     UINT r;
12329
12330     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
12331     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12332
12333     test_file_access(msifile, create);
12334
12335     r = MsiDatabaseCommit(hdb);
12336     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12337
12338     test_file_access(msifile, create_commit);
12339     MsiCloseHandle(hdb);
12340
12341     test_file_access(msifile, create_close);
12342     DeleteFileA(msifile);
12343
12344     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
12345     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12346
12347     test_file_access(msifile, create);
12348
12349     r = MsiDatabaseCommit(hdb);
12350     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12351
12352     test_file_access(msifile, create_commit);
12353     MsiCloseHandle(hdb);
12354
12355     test_file_access(msifile, create_close);
12356     DeleteFileA(msifile);
12357 }
12358
12359 static void test_emptypackage(void)
12360 {
12361     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
12362     MSIHANDLE hview = 0, hrec = 0;
12363     MSICONDITION condition;
12364     CHAR buffer[MAX_PATH];
12365     DWORD size;
12366     UINT r;
12367
12368     r = MsiOpenPackageA("", &hpkg);
12369     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12370     {
12371         skip("Not enough rights to perform tests\n");
12372         return;
12373     }
12374     todo_wine
12375     {
12376         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12377     }
12378
12379     hdb = MsiGetActiveDatabase(hpkg);
12380     todo_wine
12381     {
12382         ok(hdb != 0, "Expected a valid database handle\n");
12383     }
12384
12385     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
12386     todo_wine
12387     {
12388         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12389     }
12390     r = MsiViewExecute(hview, 0);
12391     todo_wine
12392     {
12393         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12394     }
12395
12396     r = MsiViewFetch(hview, &hrec);
12397     todo_wine
12398     {
12399         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12400     }
12401
12402     buffer[0] = 0;
12403     size = MAX_PATH;
12404     r = MsiRecordGetString(hrec, 1, buffer, &size);
12405     todo_wine
12406     {
12407         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12408         ok(!lstrcmpA(buffer, "_Property"),
12409            "Expected \"_Property\", got \"%s\"\n", buffer);
12410     }
12411
12412     MsiCloseHandle(hrec);
12413
12414     r = MsiViewFetch(hview, &hrec);
12415     todo_wine
12416     {
12417         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12418     }
12419
12420     size = MAX_PATH;
12421     r = MsiRecordGetString(hrec, 1, buffer, &size);
12422     todo_wine
12423     {
12424         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12425         ok(!lstrcmpA(buffer, "#_FolderCache"),
12426            "Expected \"_Property\", got \"%s\"\n", buffer);
12427     }
12428
12429     MsiCloseHandle(hrec);
12430     MsiViewClose(hview);
12431     MsiCloseHandle(hview);
12432
12433     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
12434     todo_wine
12435     {
12436         ok(condition == MSICONDITION_FALSE,
12437            "Expected MSICONDITION_FALSE, got %d\n", condition);
12438     }
12439
12440     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
12441     todo_wine
12442     {
12443         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12444     }
12445     r = MsiViewExecute(hview, 0);
12446     todo_wine
12447     {
12448         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12449     }
12450
12451     /* _Property table is not empty */
12452     r = MsiViewFetch(hview, &hrec);
12453     todo_wine
12454     {
12455         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12456     }
12457
12458     MsiCloseHandle(hrec);
12459     MsiViewClose(hview);
12460     MsiCloseHandle(hview);
12461
12462     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
12463     todo_wine
12464     {
12465         ok(condition == MSICONDITION_FALSE,
12466            "Expected MSICONDITION_FALSE, got %d\n", condition);
12467     }
12468
12469     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
12470     todo_wine
12471     {
12472         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12473     }
12474     r = MsiViewExecute(hview, 0);
12475     todo_wine
12476     {
12477         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12478     }
12479
12480     /* #_FolderCache is not empty */
12481     r = MsiViewFetch(hview, &hrec);
12482     todo_wine
12483     {
12484         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12485     }
12486
12487     MsiCloseHandle(hrec);
12488     MsiViewClose(hview);
12489     MsiCloseHandle(hview);
12490
12491     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
12492     todo_wine
12493     {
12494         ok(r == ERROR_BAD_QUERY_SYNTAX,
12495            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12496     }
12497
12498     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
12499     todo_wine
12500     {
12501         ok(r == ERROR_BAD_QUERY_SYNTAX,
12502            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12503     }
12504
12505     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
12506     todo_wine
12507     {
12508         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
12509            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
12510     }
12511
12512     MsiCloseHandle(hsuminfo);
12513
12514     r = MsiDatabaseCommit(hdb);
12515     todo_wine
12516     {
12517         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12518     }
12519
12520     MsiCloseHandle(hdb);
12521     MsiCloseHandle(hpkg);
12522 }
12523
12524 static void test_MsiGetProductProperty(void)
12525 {
12526     MSIHANDLE hprod, hdb;
12527     CHAR val[MAX_PATH];
12528     CHAR path[MAX_PATH];
12529     CHAR query[MAX_PATH];
12530     CHAR keypath[MAX_PATH*2];
12531     CHAR prodcode[MAX_PATH];
12532     CHAR prod_squashed[MAX_PATH];
12533     HKEY prodkey, userkey, props;
12534     DWORD size;
12535     LONG res;
12536     UINT r;
12537     REGSAM access = KEY_ALL_ACCESS;
12538
12539     GetCurrentDirectoryA(MAX_PATH, path);
12540     lstrcatA(path, "\\");
12541
12542     create_test_guid(prodcode, prod_squashed);
12543
12544     if (is_wow64)
12545         access |= KEY_WOW64_64KEY;
12546
12547     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
12548     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12549
12550     r = MsiDatabaseCommit(hdb);
12551     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12552
12553     r = set_summary_info(hdb);
12554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12555
12556     r = run_query(hdb,
12557             "CREATE TABLE `Directory` ( "
12558             "`Directory` CHAR(255) NOT NULL, "
12559             "`Directory_Parent` CHAR(255), "
12560             "`DefaultDir` CHAR(255) NOT NULL "
12561             "PRIMARY KEY `Directory`)");
12562     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12563
12564     r = run_query(hdb,
12565             "CREATE TABLE `Property` ( "
12566             "`Property` CHAR(72) NOT NULL, "
12567             "`Value` CHAR(255) "
12568             "PRIMARY KEY `Property`)");
12569     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12570
12571     sprintf(query, "INSERT INTO `Property` "
12572             "(`Property`, `Value`) "
12573             "VALUES( 'ProductCode', '%s' )", prodcode);
12574     r = run_query(hdb, query);
12575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12576
12577     r = MsiDatabaseCommit(hdb);
12578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12579
12580     MsiCloseHandle(hdb);
12581
12582     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12583     lstrcatA(keypath, prod_squashed);
12584
12585     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12586     if (res == ERROR_ACCESS_DENIED)
12587     {
12588         skip("Not enough rights to perform tests\n");
12589         DeleteFile(msifile);
12590         return;
12591     }
12592     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12593
12594     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
12595     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
12596     lstrcatA(keypath, prod_squashed);
12597
12598     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
12599     if (res == ERROR_ACCESS_DENIED)
12600     {
12601         skip("Not enough rights to perform tests\n");
12602         RegDeleteKeyA(prodkey, "");
12603         RegCloseKey(prodkey);
12604         return;
12605     }
12606     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12607
12608     res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12609     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12610
12611     lstrcpyA(val, path);
12612     lstrcatA(val, "\\");
12613     lstrcatA(val, msifile);
12614     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
12615                          (const BYTE *)val, lstrlenA(val) + 1);
12616     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12617
12618     hprod = 0xdeadbeef;
12619     r = MsiOpenProductA(prodcode, &hprod);
12620     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12621     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
12622
12623     /* hProduct is invalid */
12624     size = MAX_PATH;
12625     lstrcpyA(val, "apple");
12626     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
12627     ok(r == ERROR_INVALID_HANDLE,
12628        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12629     ok(!lstrcmpA(val, "apple"),
12630        "Expected val to be unchanged, got \"%s\"\n", val);
12631     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12632
12633     /* szProperty is NULL */
12634     size = MAX_PATH;
12635     lstrcpyA(val, "apple");
12636     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
12637     ok(r == ERROR_INVALID_PARAMETER,
12638        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12639     ok(!lstrcmpA(val, "apple"),
12640        "Expected val to be unchanged, got \"%s\"\n", val);
12641     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12642
12643     /* szProperty is empty */
12644     size = MAX_PATH;
12645     lstrcpyA(val, "apple");
12646     r = MsiGetProductPropertyA(hprod, "", val, &size);
12647     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12648     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12649     ok(size == 0, "Expected 0, got %d\n", size);
12650
12651     /* get the property */
12652     size = MAX_PATH;
12653     lstrcpyA(val, "apple");
12654     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12655     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12656     ok(!lstrcmpA(val, prodcode),
12657        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12658     ok(size == lstrlenA(prodcode),
12659        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12660
12661     /* lpValueBuf is NULL */
12662     size = MAX_PATH;
12663     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
12664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12665     ok(size == lstrlenA(prodcode),
12666        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12667
12668     /* pcchValueBuf is NULL */
12669     lstrcpyA(val, "apple");
12670     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
12671     ok(r == ERROR_INVALID_PARAMETER,
12672        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12673     ok(!lstrcmpA(val, "apple"),
12674        "Expected val to be unchanged, got \"%s\"\n", val);
12675     ok(size == lstrlenA(prodcode),
12676        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12677
12678     /* pcchValueBuf is too small */
12679     size = 4;
12680     lstrcpyA(val, "apple");
12681     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12682     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12683     ok(!strncmp(val, prodcode, 3),
12684        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
12685     ok(size == lstrlenA(prodcode),
12686        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12687
12688     /* pcchValueBuf does not leave room for NULL terminator */
12689     size = lstrlenA(prodcode);
12690     lstrcpyA(val, "apple");
12691     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12692     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12693     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
12694        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
12695     ok(size == lstrlenA(prodcode),
12696        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12697
12698     /* pcchValueBuf has enough room for NULL terminator */
12699     size = lstrlenA(prodcode) + 1;
12700     lstrcpyA(val, "apple");
12701     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12702     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12703     ok(!lstrcmpA(val, prodcode),
12704        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12705     ok(size == lstrlenA(prodcode),
12706        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12707
12708     /* nonexistent property */
12709     size = MAX_PATH;
12710     lstrcpyA(val, "apple");
12711     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
12712     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12713     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12714     ok(size == 0, "Expected 0, got %d\n", size);
12715
12716     r = MsiSetPropertyA(hprod, "NewProperty", "value");
12717     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12718
12719     /* non-product property set */
12720     size = MAX_PATH;
12721     lstrcpyA(val, "apple");
12722     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
12723     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12724     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12725     ok(size == 0, "Expected 0, got %d\n", size);
12726
12727     r = MsiSetPropertyA(hprod, "ProductCode", "value");
12728     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12729
12730     /* non-product property that is also a product property set */
12731     size = MAX_PATH;
12732     lstrcpyA(val, "apple");
12733     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12735     ok(!lstrcmpA(val, prodcode),
12736        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12737     ok(size == lstrlenA(prodcode),
12738        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12739
12740     MsiCloseHandle(hprod);
12741
12742     RegDeleteValueA(props, "LocalPackage");
12743     delete_key(props, "", access);
12744     RegCloseKey(props);
12745     delete_key(userkey, "", access);
12746     RegCloseKey(userkey);
12747     delete_key(prodkey, "", access);
12748     RegCloseKey(prodkey);
12749     DeleteFileA(msifile);
12750 }
12751
12752 static void test_MsiSetProperty(void)
12753 {
12754     MSIHANDLE hpkg, hdb, hrec;
12755     CHAR buf[MAX_PATH];
12756     LPCSTR query;
12757     DWORD size;
12758     UINT r;
12759
12760     r = package_from_db(create_package_db(), &hpkg);
12761     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12762     {
12763         skip("Not enough rights to perform tests\n");
12764         DeleteFile(msifile);
12765         return;
12766     }
12767     ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
12768
12769     /* invalid hInstall */
12770     r = MsiSetPropertyA(0, "Prop", "Val");
12771     ok(r == ERROR_INVALID_HANDLE,
12772        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12773
12774     /* invalid hInstall */
12775     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
12776     ok(r == ERROR_INVALID_HANDLE,
12777        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12778
12779     /* szName is NULL */
12780     r = MsiSetPropertyA(hpkg, NULL, "Val");
12781     ok(r == ERROR_INVALID_PARAMETER,
12782        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12783
12784     /* both szName and szValue are NULL */
12785     r = MsiSetPropertyA(hpkg, NULL, NULL);
12786     ok(r == ERROR_INVALID_PARAMETER,
12787        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12788
12789     /* szName is empty */
12790     r = MsiSetPropertyA(hpkg, "", "Val");
12791     ok(r == ERROR_FUNCTION_FAILED,
12792        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
12793
12794     /* szName is empty and szValue is NULL */
12795     r = MsiSetPropertyA(hpkg, "", NULL);
12796     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12797
12798     /* set a property */
12799     r = MsiSetPropertyA(hpkg, "Prop", "Val");
12800     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12801
12802     /* get the property */
12803     size = MAX_PATH;
12804     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12805     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12806     ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
12807     ok(size == 3, "Expected 3, got %d\n", size);
12808
12809     /* update the property */
12810     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
12811     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12812
12813     /* get the property */
12814     size = MAX_PATH;
12815     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12817     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
12818     ok(size == 4, "Expected 4, got %d\n", size);
12819
12820     hdb = MsiGetActiveDatabase(hpkg);
12821     ok(hdb != 0, "Expected a valid database handle\n");
12822
12823     /* set prop is not in the _Property table */
12824     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
12825     r = do_query(hdb, query, &hrec);
12826     ok(r == ERROR_BAD_QUERY_SYNTAX,
12827        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12828
12829     /* set prop is not in the Property table */
12830     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
12831     r = do_query(hdb, query, &hrec);
12832     ok(r == ERROR_BAD_QUERY_SYNTAX,
12833        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12834
12835     MsiCloseHandle(hdb);
12836
12837     /* szValue is an empty string */
12838     r = MsiSetPropertyA(hpkg, "Prop", "");
12839     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12840
12841     /* try to get the property */
12842     size = MAX_PATH;
12843     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12844     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12845     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12846     ok(size == 0, "Expected 0, got %d\n", size);
12847
12848     /* reset the property */
12849     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
12850     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12851
12852     /* delete the property */
12853     r = MsiSetPropertyA(hpkg, "Prop", NULL);
12854     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12855
12856     /* try to get the property */
12857     size = MAX_PATH;
12858     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12859     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12860     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12861     ok(size == 0, "Expected 0, got %d\n", size);
12862
12863     MsiCloseHandle(hpkg);
12864     DeleteFileA(msifile);
12865 }
12866
12867 static void test_MsiApplyMultiplePatches(void)
12868 {
12869     UINT r, type = GetDriveType(NULL);
12870
12871     if (!pMsiApplyMultiplePatchesA) {
12872         win_skip("MsiApplyMultiplePatchesA not found\n");
12873         return;
12874     }
12875
12876     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
12877     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12878
12879     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
12880     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12881
12882     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
12883     if (type == DRIVE_FIXED)
12884         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12885     else
12886         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12887
12888     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
12889     if (type == DRIVE_FIXED)
12890         todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
12891     else
12892         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12893
12894     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
12895     if (type == DRIVE_FIXED)
12896         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12897     else
12898         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12899
12900     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
12901     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12902
12903     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
12904     if (type == DRIVE_FIXED)
12905         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12906     else
12907         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12908
12909     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
12910     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12911
12912     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
12913     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12914 }
12915
12916 static void test_MsiApplyPatch(void)
12917 {
12918     UINT r;
12919
12920     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
12921     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12922
12923     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
12924     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12925 }
12926
12927 static void test_MsiEnumComponentCosts(void)
12928 {
12929     MSIHANDLE hdb, hpkg;
12930     char package[12], drive[3];
12931     DWORD len;
12932     UINT r;
12933     int cost, temp;
12934
12935     hdb = create_package_db();
12936     ok( hdb, "failed to create database\n" );
12937
12938     r = create_property_table( hdb );
12939     ok( r == ERROR_SUCCESS, "cannot create Property table %u\n", r );
12940
12941     r = add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
12942     ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
12943
12944     r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
12945     ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
12946
12947     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
12948     ok( r == ERROR_SUCCESS, "failed to add directory entry %u\n" , r );
12949
12950     r = create_media_table( hdb );
12951     ok( r == ERROR_SUCCESS, "cannot create Media table %u\n", r );
12952
12953     r = add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
12954     ok( r == ERROR_SUCCESS, "cannot add media entry %u\n", r );
12955
12956     r = create_file_table( hdb );
12957     ok( r == ERROR_SUCCESS, "cannot create File table %u\n", r );
12958
12959     r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
12960     ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
12961
12962     r = create_component_table( hdb );
12963     ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
12964
12965     r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
12966     ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
12967
12968     r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
12969     ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
12970
12971     r = create_feature_table( hdb );
12972     ok( r == ERROR_SUCCESS, "cannot create Feature table %u\n", r );
12973
12974     r = add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
12975     ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
12976
12977     r = add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
12978     ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
12979
12980     r = create_feature_components_table( hdb );
12981     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table %u\n", r );
12982
12983     r = add_feature_components_entry( hdb, "'one', 'one'" );
12984     ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
12985
12986     r = add_feature_components_entry( hdb, "'two', 'two'" );
12987     ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
12988
12989     r = create_install_execute_sequence_table( hdb );
12990     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table %u\n", r );
12991
12992     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
12993     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
12994
12995     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
12996     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
12997
12998     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
12999     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
13000
13001     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
13002     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
13003
13004     MsiDatabaseCommit( hdb );
13005
13006     sprintf( package, "#%u", hdb );
13007     r = MsiOpenPackageA( package, &hpkg );
13008     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13009     {
13010         skip("Not enough rights to perform tests\n");
13011         goto error;
13012     }
13013     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13014
13015     r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
13016     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13017
13018     r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
13019     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13020
13021     r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
13022     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13023
13024     r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
13025     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13026
13027     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
13028     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13029
13030     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
13031     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13032
13033     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
13034     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13035
13036     len = sizeof(drive);
13037     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
13038     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13039
13040     len = sizeof(drive);
13041     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
13042     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13043
13044     len = sizeof(drive);
13045     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13046     todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
13047
13048     len = sizeof(drive);
13049     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
13050     ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
13051
13052     MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
13053
13054     r = MsiDoAction( hpkg, "CostInitialize" );
13055     ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
13056
13057     r = MsiDoAction( hpkg, "FileCost" );
13058     ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
13059
13060     len = sizeof(drive);
13061     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13062     ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
13063
13064     r = MsiDoAction( hpkg, "CostFinalize" );
13065     ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
13066
13067     /* contrary to what msdn says InstallValidate must be called too */
13068     len = sizeof(drive);
13069     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13070     todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
13071
13072     r = MsiDoAction( hpkg, "InstallValidate" );
13073     ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
13074
13075     len = 0;
13076     r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13077     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
13078
13079     len = 0;
13080     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13081     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
13082     ok( len == 2, "expected len == 2, got %u\n", len );
13083
13084     len = 2;
13085     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13086     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
13087     ok( len == 2, "expected len == 2, got %u\n", len );
13088
13089     len = 2;
13090     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
13091     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
13092     ok( len == 2, "expected len == 2, got %u\n", len );
13093
13094     /* install state doesn't seem to matter */
13095     len = sizeof(drive);
13096     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
13097     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13098
13099     len = sizeof(drive);
13100     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
13101     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13102
13103     len = sizeof(drive);
13104     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
13105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13106
13107     len = sizeof(drive);
13108     drive[0] = 0;
13109     cost = temp = 0xdead;
13110     r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13111     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13112     ok( len == 2, "expected len == 2, got %u\n", len );
13113     ok( drive[0], "expected a drive\n" );
13114     ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
13115     ok( !temp, "expected temp == 0, got %d\n", temp );
13116
13117     len = sizeof(drive);
13118     drive[0] = 0;
13119     cost = temp = 0xdead;
13120     r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13122     ok( len == 2, "expected len == 2, got %u\n", len );
13123     ok( drive[0], "expected a drive\n" );
13124     ok( !cost, "expected cost == 0, got %d\n", cost );
13125     ok( !temp, "expected temp == 0, got %d\n", temp );
13126
13127     len = sizeof(drive);
13128     drive[0] = 0;
13129     cost = temp = 0xdead;
13130     r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
13131     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
13132     ok( len == 2, "expected len == 2, got %u\n", len );
13133     ok( drive[0], "expected a drive\n" );
13134     ok( !cost, "expected cost == 0, got %d\n", cost );
13135     ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
13136
13137     /* increased index */
13138     len = sizeof(drive);
13139     r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
13140     ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
13141
13142     len = sizeof(drive);
13143     r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
13144     ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
13145
13146     MsiCloseHandle( hpkg );
13147 error:
13148     MsiCloseHandle( hdb );
13149     DeleteFileA( msifile );
13150 }
13151
13152 START_TEST(package)
13153 {
13154     STATEMGRSTATUS status;
13155     BOOL ret = FALSE;
13156
13157     init_functionpointers();
13158
13159     if (pIsWow64Process)
13160         pIsWow64Process(GetCurrentProcess(), &is_wow64);
13161
13162     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
13163
13164     /* Create a restore point ourselves so we circumvent the multitude of restore points
13165      * that would have been created by all the installation and removal tests.
13166      *
13167      * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
13168      * creation of restore points.
13169      */
13170     if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
13171     {
13172         memset(&status, 0, sizeof(status));
13173         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
13174     }
13175
13176     test_createpackage();
13177     test_doaction();
13178     test_gettargetpath_bad();
13179     test_settargetpath();
13180     test_props();
13181     test_property_table();
13182     test_condition();
13183     test_msipackage();
13184     test_formatrecord2();
13185     test_states();
13186     test_getproperty();
13187     test_removefiles();
13188     test_appsearch();
13189     test_appsearch_complocator();
13190     test_appsearch_reglocator();
13191     test_appsearch_inilocator();
13192     test_appsearch_drlocator();
13193     test_featureparents();
13194     test_installprops();
13195     test_launchconditions();
13196     test_ccpsearch();
13197     test_complocator();
13198     test_MsiGetSourcePath();
13199     test_shortlongsource();
13200     test_sourcedir();
13201     test_access();
13202     test_emptypackage();
13203     test_MsiGetProductProperty();
13204     test_MsiSetProperty();
13205     test_MsiApplyMultiplePatches();
13206     test_MsiApplyPatch();
13207     test_MsiEnumComponentCosts();
13208
13209     if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
13210     {
13211         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
13212         if (ret)
13213             remove_restore_point(status.llSequenceNumber);
13214     }
13215 }