mshtml: Added IHTMLWindow2::focus implementation.
[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 LPSTR get_user_sid(LPSTR *usersid)
113 {
114     HANDLE token;
115     BYTE buf[1024];
116     DWORD size;
117     PTOKEN_USER user;
118
119     if (!pConvertSidToStringSidA)
120     {
121         win_skip("ConvertSidToStringSidA is not available\n");
122         return NULL;
123     }
124
125     *usersid = NULL;
126     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
127     size = sizeof(buf);
128     GetTokenInformation(token, TokenUser, buf, size, &size);
129     user = (PTOKEN_USER)buf;
130     pConvertSidToStringSidA(user->User.Sid, usersid);
131     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
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
757     res = run_query( hdb,
758             "CREATE TABLE `Directory` ( "
759             "`Directory` CHAR(255) NOT NULL, "
760             "`Directory_Parent` CHAR(255), "
761             "`DefaultDir` CHAR(255) NOT NULL "
762             "PRIMARY KEY `Directory`)" );
763     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
764
765     return hdb;
766 }
767
768 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
769 {
770     UINT res;
771     CHAR szPackage[12];
772     MSIHANDLE hPackage;
773
774     sprintf(szPackage, "#%u", hdb);
775     res = MsiOpenPackage(szPackage, &hPackage);
776     if (res != ERROR_SUCCESS)
777     {
778         MsiCloseHandle(hdb);
779         return res;
780     }
781
782     res = MsiCloseHandle(hdb);
783     if (res != ERROR_SUCCESS)
784     {
785         MsiCloseHandle(hPackage);
786         return res;
787     }
788
789     *handle = hPackage;
790     return ERROR_SUCCESS;
791 }
792
793 static void create_test_file(const CHAR *name)
794 {
795     HANDLE file;
796     DWORD written;
797
798     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
799     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
800     WriteFile(file, name, strlen(name), &written, NULL);
801     WriteFile(file, "\n", strlen("\n"), &written, NULL);
802     CloseHandle(file);
803 }
804
805 typedef struct _tagVS_VERSIONINFO
806 {
807     WORD wLength;
808     WORD wValueLength;
809     WORD wType;
810     WCHAR szKey[1];
811     WORD wPadding1[1];
812     VS_FIXEDFILEINFO Value;
813     WORD wPadding2[1];
814     WORD wChildren[1];
815 } VS_VERSIONINFO;
816
817 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
818 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
819
820 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
821 {
822     VS_VERSIONINFO *pVerInfo;
823     VS_FIXEDFILEINFO *pFixedInfo;
824     LPBYTE buffer, ofs;
825     CHAR path[MAX_PATH];
826     DWORD handle, size;
827     HANDLE resource;
828     BOOL ret = FALSE;
829
830     GetSystemDirectory(path, MAX_PATH);
831     /* Some dlls can't be updated on Vista/W2K8 */
832     lstrcatA(path, "\\version.dll");
833
834     CopyFileA(path, name, FALSE);
835
836     size = GetFileVersionInfoSize(path, &handle);
837     buffer = HeapAlloc(GetProcessHeap(), 0, size);
838
839     GetFileVersionInfoA(path, 0, size, buffer);
840
841     pVerInfo = (VS_VERSIONINFO *)buffer;
842     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
843     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
844
845     pFixedInfo->dwFileVersionMS = ms;
846     pFixedInfo->dwFileVersionLS = ls;
847     pFixedInfo->dwProductVersionMS = ms;
848     pFixedInfo->dwProductVersionLS = ls;
849
850     resource = BeginUpdateResource(name, FALSE);
851     if (!resource)
852         goto done;
853
854     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
855                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
856         goto done;
857
858     if (!EndUpdateResource(resource, FALSE))
859         goto done;
860
861     ret = TRUE;
862
863 done:
864     HeapFree(GetProcessHeap(), 0, buffer);
865     return ret;
866 }
867
868 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
869 {
870     RESTOREPOINTINFOA spec;
871
872     spec.dwEventType = event_type;
873     spec.dwRestorePtType = APPLICATION_INSTALL;
874     spec.llSequenceNumber = status->llSequenceNumber;
875     lstrcpyA(spec.szDescription, "msitest restore point");
876
877     return pSRSetRestorePointA(&spec, status);
878 }
879
880 static void remove_restore_point(DWORD seq_number)
881 {
882     DWORD res;
883
884     res = pSRRemoveRestorePoint(seq_number);
885     if (res != ERROR_SUCCESS)
886         trace("Failed to remove the restore point : %08x\n", res);
887 }
888
889 static void test_createpackage(void)
890 {
891     MSIHANDLE hPackage = 0;
892     UINT res;
893
894     res = package_from_db(create_package_db(), &hPackage);
895     if (res == ERROR_INSTALL_PACKAGE_REJECTED)
896     {
897         skip("Not enough rights to perform tests\n");
898         DeleteFile(msifile);
899         return;
900     }
901     ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
902
903     res = MsiCloseHandle( hPackage);
904     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
905     DeleteFile(msifile);
906 }
907
908 static void test_doaction( void )
909 {
910     MSIHANDLE hpkg;
911     UINT r;
912
913     r = MsiDoAction( -1, NULL );
914     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
915
916     r = package_from_db(create_package_db(), &hpkg);
917     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
918     {
919         skip("Not enough rights to perform tests\n");
920         DeleteFile(msifile);
921         return;
922     }
923     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
924
925     r = MsiDoAction(hpkg, NULL);
926     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
927
928     r = MsiDoAction(0, "boo");
929     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
930
931     r = MsiDoAction(hpkg, "boo");
932     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
933
934     MsiCloseHandle( hpkg );
935     DeleteFile(msifile);
936 }
937
938 static void test_gettargetpath_bad(void)
939 {
940     static const WCHAR boo[] = {'b','o','o',0};
941     static const WCHAR empty[] = {0};
942     char buffer[0x80];
943     WCHAR bufferW[0x80];
944     MSIHANDLE hpkg;
945     DWORD sz;
946     UINT r;
947
948     r = package_from_db(create_package_db(), &hpkg);
949     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
950     {
951         skip("Not enough rights to perform tests\n");
952         DeleteFile(msifile);
953         return;
954     }
955     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
956
957     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
958     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
959
960     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
961     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
962
963     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
964     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
965
966     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
967     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
968
969     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
970     ok( r == ERROR_DIRECTORY, "wrong return val\n");
971
972     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
973     ok( r == ERROR_DIRECTORY, "wrong return val\n");
974
975     sz = 0;
976     r = MsiGetTargetPath( hpkg, "", buffer, &sz );
977     ok( r == ERROR_DIRECTORY, "wrong return val\n");
978
979     r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
980     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
981
982     r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
983     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
984
985     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
986     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
987
988     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
989     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
990
991     r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
992     ok( r == ERROR_DIRECTORY, "wrong return val\n");
993
994     r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
995     ok( r == ERROR_DIRECTORY, "wrong return val\n");
996
997     sz = 0;
998     r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
999     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1000
1001     MsiCloseHandle( hpkg );
1002     DeleteFile(msifile);
1003 }
1004
1005 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1006 {
1007     UINT r;
1008     DWORD size;
1009     MSIHANDLE rec;
1010
1011     rec = MsiCreateRecord( 1 );
1012     ok(rec, "MsiCreate record failed\n");
1013
1014     r = MsiRecordSetString( rec, 0, file );
1015     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1016
1017     size = MAX_PATH;
1018     r = MsiFormatRecord( hpkg, rec, buff, &size );
1019     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1020
1021     MsiCloseHandle( rec );
1022 }
1023
1024 static void test_settargetpath(void)
1025 {
1026     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1027     DWORD sz;
1028     MSIHANDLE hpkg;
1029     UINT r;
1030     MSIHANDLE hdb;
1031
1032     hdb = create_package_db();
1033     ok ( hdb, "failed to create package database\n" );
1034
1035     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1036     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1037
1038     r = create_component_table( hdb );
1039     ok( r == S_OK, "cannot create Component table: %d\n", r );
1040
1041     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1042     ok( r == S_OK, "cannot add dummy component: %d\n", r );
1043
1044     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1045     ok( r == S_OK, "cannot add test component: %d\n", r );
1046
1047     r = create_feature_table( hdb );
1048     ok( r == S_OK, "cannot create Feature table: %d\n", r );
1049
1050     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1051     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1052
1053     r = create_feature_components_table( hdb );
1054     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1055
1056     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1057     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1058
1059     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1060     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1061
1062     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1063     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1064
1065     r = create_file_table( hdb );
1066     ok( r == S_OK, "cannot create File table: %d\n", r );
1067
1068     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1069     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1070
1071     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1072     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1073
1074     r = package_from_db( hdb, &hpkg );
1075     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1076     {
1077         skip("Not enough rights to perform tests\n");
1078         DeleteFile(msifile);
1079         return;
1080     }
1081     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1082
1083     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1084
1085     r = MsiDoAction( hpkg, "CostInitialize");
1086     ok( r == ERROR_SUCCESS, "cost init failed\n");
1087
1088     r = MsiDoAction( hpkg, "FileCost");
1089     ok( r == ERROR_SUCCESS, "file cost failed\n");
1090
1091     r = MsiDoAction( hpkg, "CostFinalize");
1092     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1093
1094     r = MsiSetTargetPath( 0, NULL, NULL );
1095     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1096
1097     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1098     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1099
1100     r = MsiSetTargetPath( hpkg, "boo", NULL );
1101     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1102
1103     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1104     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1105
1106     sz = sizeof tempdir - 1;
1107     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1108     sprintf( file, "%srootfile.txt", tempdir );
1109     buffer[0] = 0;
1110     query_file_path( hpkg, "[#RootFile]", buffer );
1111     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1112     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1113
1114     GetTempFileName( tempdir, "_wt", 0, buffer );
1115     sprintf( tempdir, "%s\\subdir", buffer );
1116
1117     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1118     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1119         "MsiSetTargetPath on file returned %d\n", r );
1120
1121     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1122     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1123         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1124
1125     DeleteFile( buffer );
1126
1127     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1128     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1129
1130     r = GetFileAttributes( buffer );
1131     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1132
1133     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1134     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1135
1136     sz = sizeof buffer - 1;
1137     lstrcat( tempdir, "\\" );
1138     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1139     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1140     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1141
1142     sprintf( file, "%srootfile.txt", tempdir );
1143     query_file_path( hpkg, "[#RootFile]", buffer );
1144     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1145
1146     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1147     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1148
1149     query_file_path( hpkg, "[#TestFile]", buffer );
1150     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1151         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1152
1153     sz = sizeof buffer - 1;
1154     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1155     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1156     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1157
1158     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1159     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1160
1161     sz = sizeof buffer - 1;
1162     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1163     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1164     ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1165
1166     MsiCloseHandle( hpkg );
1167 }
1168
1169 static void test_condition(void)
1170 {
1171     static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1172     static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1173     static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1174     static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1175     MSICONDITION r;
1176     MSIHANDLE hpkg;
1177
1178     r = package_from_db(create_package_db(), &hpkg);
1179     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1180     {
1181         skip("Not enough rights to perform tests\n");
1182         DeleteFile(msifile);
1183         return;
1184     }
1185     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1186
1187     r = MsiEvaluateCondition(0, NULL);
1188     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1189
1190     r = MsiEvaluateCondition(hpkg, NULL);
1191     ok( r == MSICONDITION_NONE, "wrong return val\n");
1192
1193     r = MsiEvaluateCondition(hpkg, "");
1194     ok( r == MSICONDITION_NONE, "wrong return val\n");
1195
1196     r = MsiEvaluateCondition(hpkg, "1");
1197     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1198
1199     r = MsiEvaluateCondition(hpkg, "0");
1200     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1201
1202     r = MsiEvaluateCondition(hpkg, "-1");
1203     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1204
1205     r = MsiEvaluateCondition(hpkg, "0 = 0");
1206     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1207
1208     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1209     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1210
1211     r = MsiEvaluateCondition(hpkg, "0 = 1");
1212     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1213
1214     r = MsiEvaluateCondition(hpkg, "0 > 1");
1215     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1216
1217     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1218     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1219
1220     r = MsiEvaluateCondition(hpkg, "1 > 1");
1221     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1222
1223     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1224     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1225
1226     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1227     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1228
1229     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1230     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1231
1232     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1233     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1234
1235     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1236     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1237
1238     r = MsiEvaluateCondition(hpkg, "0 < 1");
1239     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1240
1241     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1242     ok( r == MSICONDITION_TRUE, "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, "1 ~< 1");
1248     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1249
1250     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1251     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1252
1253     r = MsiEvaluateCondition(hpkg, "0 ~<= 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, "1 ~<= 1");
1260     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "0 >=");
1263     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, " ");
1266     ok( r == MSICONDITION_NONE, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1269     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1272     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1275     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, "not 0");
1278     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, "not LicView");
1281     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1284     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1287     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1290     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1293     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1296     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, "\"0\"");
1299     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, "1 and 2");
1302     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1305     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1308     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1311     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, "(0)");
1314     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1317     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1318
1319     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1320     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1321
1322     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1323     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1324
1325     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1326     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1327
1328     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1329     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330
1331     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1332     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333
1334     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1335     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1336
1337     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1338     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1339
1340     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1341     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1342
1343     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1344     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1345
1346     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1347     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1348
1349     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1350     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1351
1352     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1353     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1354
1355     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1356     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1357
1358     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1359     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1360
1361     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1362     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1363
1364     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1365     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1366
1367     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1368     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1369
1370     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1371     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1372
1373     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1374     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1375
1376     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1377     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1378
1379     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1380     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1381
1382     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1383     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1384
1385     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1386     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1387
1388     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1389     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1390
1391     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1392     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1393
1394     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1395     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1396
1397     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1398     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1399
1400     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1401     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1402
1403     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1404     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1405
1406     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1407     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1408
1409     MsiSetProperty(hpkg, "mm", "5" );
1410
1411     r = MsiEvaluateCondition(hpkg, "mm = 5");
1412     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1413
1414     r = MsiEvaluateCondition(hpkg, "mm < 6");
1415     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1416
1417     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1418     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1419
1420     r = MsiEvaluateCondition(hpkg, "mm > 4");
1421     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1422
1423     r = MsiEvaluateCondition(hpkg, "mm < 12");
1424     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1425
1426     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1427     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1430     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1431
1432     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1433     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1434
1435     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1436     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1437
1438     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1439     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1440
1441     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1442     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1445     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1446
1447     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1448     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1449
1450     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1451     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1452
1453     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1454     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1455
1456     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1457     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1458
1459     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1460     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1461
1462     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1463     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1464
1465     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1466     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1467
1468     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1469     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1470
1471     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1472     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1473
1474     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1475     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1476
1477     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1478     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1479
1480     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1481     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1482
1483     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1484     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1485
1486     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1487     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488
1489     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1490     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1491
1492     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1493     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1494
1495     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1496     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1497
1498     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1499     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1500
1501     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1502     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1503
1504     MsiSetProperty(hpkg, "bandalmael", "0" );
1505     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1506     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1507
1508     MsiSetProperty(hpkg, "bandalmael", "" );
1509     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1510     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1511
1512     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1513     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1514     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1515
1516     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1517     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1518     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1519
1520     MsiSetProperty(hpkg, "bandalmael", "0 " );
1521     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1522     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1523
1524     MsiSetProperty(hpkg, "bandalmael", "-0" );
1525     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1526     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1527
1528     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1529     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1530     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1531
1532     MsiSetProperty(hpkg, "bandalmael", "--0" );
1533     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1534     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1535
1536     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1537     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1538     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1539
1540     MsiSetProperty(hpkg, "bandalmael", "-" );
1541     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1542     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1543
1544     MsiSetProperty(hpkg, "bandalmael", "+0" );
1545     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1546     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1547
1548     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1549     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1550     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1551     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1552     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1553
1554     MsiSetProperty(hpkg, "one", "hi");
1555     MsiSetProperty(hpkg, "two", "hithere");
1556     r = MsiEvaluateCondition(hpkg, "one >< two");
1557     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1558
1559     MsiSetProperty(hpkg, "one", "hithere");
1560     MsiSetProperty(hpkg, "two", "hi");
1561     r = MsiEvaluateCondition(hpkg, "one >< two");
1562     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1563
1564     MsiSetProperty(hpkg, "one", "hello");
1565     MsiSetProperty(hpkg, "two", "hi");
1566     r = MsiEvaluateCondition(hpkg, "one >< two");
1567     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1568
1569     MsiSetProperty(hpkg, "one", "hellohithere");
1570     MsiSetProperty(hpkg, "two", "hi");
1571     r = MsiEvaluateCondition(hpkg, "one >< two");
1572     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1573
1574     MsiSetProperty(hpkg, "one", "");
1575     MsiSetProperty(hpkg, "two", "hi");
1576     r = MsiEvaluateCondition(hpkg, "one >< two");
1577     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1578
1579     MsiSetProperty(hpkg, "one", "hi");
1580     MsiSetProperty(hpkg, "two", "");
1581     r = MsiEvaluateCondition(hpkg, "one >< two");
1582     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1583
1584     MsiSetProperty(hpkg, "one", "");
1585     MsiSetProperty(hpkg, "two", "");
1586     r = MsiEvaluateCondition(hpkg, "one >< two");
1587     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1588
1589     MsiSetProperty(hpkg, "one", "1234");
1590     MsiSetProperty(hpkg, "two", "1");
1591     r = MsiEvaluateCondition(hpkg, "one >< two");
1592     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1593
1594     MsiSetProperty(hpkg, "one", "one 1234");
1595     MsiSetProperty(hpkg, "two", "1");
1596     r = MsiEvaluateCondition(hpkg, "one >< two");
1597     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1598
1599     MsiSetProperty(hpkg, "one", "hithere");
1600     MsiSetProperty(hpkg, "two", "hi");
1601     r = MsiEvaluateCondition(hpkg, "one << two");
1602     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1603
1604     MsiSetProperty(hpkg, "one", "hi");
1605     MsiSetProperty(hpkg, "two", "hithere");
1606     r = MsiEvaluateCondition(hpkg, "one << two");
1607     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1608
1609     MsiSetProperty(hpkg, "one", "hi");
1610     MsiSetProperty(hpkg, "two", "hi");
1611     r = MsiEvaluateCondition(hpkg, "one << two");
1612     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1613
1614     MsiSetProperty(hpkg, "one", "abcdhithere");
1615     MsiSetProperty(hpkg, "two", "hi");
1616     r = MsiEvaluateCondition(hpkg, "one << two");
1617     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1618
1619     MsiSetProperty(hpkg, "one", "");
1620     MsiSetProperty(hpkg, "two", "hi");
1621     r = MsiEvaluateCondition(hpkg, "one << two");
1622     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1623
1624     MsiSetProperty(hpkg, "one", "hithere");
1625     MsiSetProperty(hpkg, "two", "");
1626     r = MsiEvaluateCondition(hpkg, "one << two");
1627     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1628
1629     MsiSetProperty(hpkg, "one", "");
1630     MsiSetProperty(hpkg, "two", "");
1631     r = MsiEvaluateCondition(hpkg, "one << two");
1632     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1633
1634     MsiSetProperty(hpkg, "one", "1234");
1635     MsiSetProperty(hpkg, "two", "1");
1636     r = MsiEvaluateCondition(hpkg, "one << two");
1637     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1638
1639     MsiSetProperty(hpkg, "one", "1234 one");
1640     MsiSetProperty(hpkg, "two", "1");
1641     r = MsiEvaluateCondition(hpkg, "one << two");
1642     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1643
1644     MsiSetProperty(hpkg, "one", "hithere");
1645     MsiSetProperty(hpkg, "two", "there");
1646     r = MsiEvaluateCondition(hpkg, "one >> two");
1647     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1648
1649     MsiSetProperty(hpkg, "one", "hithere");
1650     MsiSetProperty(hpkg, "two", "hi");
1651     r = MsiEvaluateCondition(hpkg, "one >> two");
1652     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1653
1654     MsiSetProperty(hpkg, "one", "there");
1655     MsiSetProperty(hpkg, "two", "hithere");
1656     r = MsiEvaluateCondition(hpkg, "one >> two");
1657     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1658
1659     MsiSetProperty(hpkg, "one", "there");
1660     MsiSetProperty(hpkg, "two", "there");
1661     r = MsiEvaluateCondition(hpkg, "one >> two");
1662     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1663
1664     MsiSetProperty(hpkg, "one", "abcdhithere");
1665     MsiSetProperty(hpkg, "two", "hi");
1666     r = MsiEvaluateCondition(hpkg, "one >> two");
1667     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1668
1669     MsiSetProperty(hpkg, "one", "");
1670     MsiSetProperty(hpkg, "two", "there");
1671     r = MsiEvaluateCondition(hpkg, "one >> two");
1672     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1673
1674     MsiSetProperty(hpkg, "one", "there");
1675     MsiSetProperty(hpkg, "two", "");
1676     r = MsiEvaluateCondition(hpkg, "one >> two");
1677     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1678
1679     MsiSetProperty(hpkg, "one", "");
1680     MsiSetProperty(hpkg, "two", "");
1681     r = MsiEvaluateCondition(hpkg, "one >> two");
1682     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1683
1684     MsiSetProperty(hpkg, "one", "1234");
1685     MsiSetProperty(hpkg, "two", "4");
1686     r = MsiEvaluateCondition(hpkg, "one >> two");
1687     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1688
1689     MsiSetProperty(hpkg, "one", "one 1234");
1690     MsiSetProperty(hpkg, "two", "4");
1691     r = MsiEvaluateCondition(hpkg, "one >> two");
1692     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1693
1694     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1695
1696     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1697     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1698
1699     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1700     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1701
1702     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1703     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1704
1705     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1706     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1707
1708     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1709     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1710
1711     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1712     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1713
1714     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1715     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1716
1717     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1718     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1719
1720     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1721     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1722
1723     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1724     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1725
1726     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1727     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1728
1729     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1730     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1731
1732     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1733     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1734
1735     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1736     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1737
1738     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1739     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1740
1741     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1742     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1743
1744     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1745     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1746
1747     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1748     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749
1750     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1751     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1752
1753     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1754     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1755
1756     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1757     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1758
1759     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1760     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1761
1762     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1763     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1764
1765     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1766     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1767
1768     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1769     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1770
1771     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1772     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1773
1774     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1775     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1776
1777     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1778     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1779
1780     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1781     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1782
1783     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1784     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1785
1786     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1787     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1788
1789     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1790     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1791
1792     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1793     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1794
1795     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1796     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1797
1798     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1799     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1800
1801     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"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     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1808     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1809     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1810
1811     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1812     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1813
1814     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1815     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1816
1817     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1818     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1819
1820     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1821     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1822
1823     MsiSetProperty(hpkg, "one", "1");
1824     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1825     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1826
1827     MsiSetProperty(hpkg, "X", "5.0");
1828
1829     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1830     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1831
1832     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1833     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1834
1835     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1836     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1837
1838     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1839     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1840
1841     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1842     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1843
1844     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1845     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1846
1847     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1848     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1849
1850     /* feature doesn't exist */
1851     r = MsiEvaluateCondition(hpkg, "&nofeature");
1852     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1853
1854     MsiSetProperty(hpkg, "A", "2");
1855     MsiSetProperty(hpkg, "X", "50");
1856
1857     r = MsiEvaluateCondition(hpkg, "2 <= X");
1858     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1859
1860     r = MsiEvaluateCondition(hpkg, "A <= X");
1861     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1862
1863     r = MsiEvaluateCondition(hpkg, "A <= 50");
1864     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1865
1866     MsiSetProperty(hpkg, "X", "50val");
1867
1868     r = MsiEvaluateCondition(hpkg, "2 <= X");
1869     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1870
1871     r = MsiEvaluateCondition(hpkg, "A <= X");
1872     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1873
1874     MsiSetProperty(hpkg, "A", "7");
1875     MsiSetProperty(hpkg, "X", "50");
1876
1877     r = MsiEvaluateCondition(hpkg, "7 <= X");
1878     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1879
1880     r = MsiEvaluateCondition(hpkg, "A <= X");
1881     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1882
1883     r = MsiEvaluateCondition(hpkg, "A <= 50");
1884     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1885
1886     MsiSetProperty(hpkg, "X", "50val");
1887
1888     r = MsiEvaluateCondition(hpkg, "2 <= X");
1889     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1890
1891     r = MsiEvaluateCondition(hpkg, "A <= X");
1892     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1893
1894     r = MsiEvaluateConditionW(hpkg, cond1);
1895     ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1896         "wrong return val (%d)\n", r);
1897
1898     r = MsiEvaluateConditionW(hpkg, cond2);
1899     ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1900         "wrong return val (%d)\n", r);
1901
1902     r = MsiEvaluateConditionW(hpkg, cond3);
1903     ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1904         "wrong return val (%d)\n", r);
1905
1906     r = MsiEvaluateConditionW(hpkg, cond4);
1907     ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1908         "wrong return val (%d)\n", r);
1909
1910     MsiCloseHandle( hpkg );
1911     DeleteFile(msifile);
1912 }
1913
1914 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1915 {
1916     UINT r;
1917     DWORD sz;
1918     char buffer[2];
1919
1920     sz = sizeof buffer;
1921     strcpy(buffer,"x");
1922     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1923     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1924 }
1925
1926 static void test_props(void)
1927 {
1928     MSIHANDLE hpkg, hdb;
1929     UINT r;
1930     DWORD sz;
1931     char buffer[0x100];
1932
1933     hdb = create_package_db();
1934     r = run_query( hdb,
1935             "CREATE TABLE `Property` ( "
1936             "`Property` CHAR(255) NOT NULL, "
1937             "`Value` CHAR(255) "
1938             "PRIMARY KEY `Property`)" );
1939     ok( r == ERROR_SUCCESS , "Failed\n" );
1940
1941     r = run_query(hdb,
1942             "INSERT INTO `Property` "
1943             "(`Property`, `Value`) "
1944             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1945     ok( r == ERROR_SUCCESS , "Failed\n" );
1946
1947     r = package_from_db( hdb, &hpkg );
1948     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1949     {
1950         skip("Not enough rights to perform tests\n");
1951         DeleteFile(msifile);
1952         return;
1953     }
1954     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1955
1956     /* test invalid values */
1957     r = MsiGetProperty( 0, NULL, NULL, NULL );
1958     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1959
1960     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1961     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1962
1963     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1964     ok( r == ERROR_SUCCESS, "wrong return val\n");
1965
1966     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1967     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1968
1969     /* test retrieving an empty/nonexistent property */
1970     sz = sizeof buffer;
1971     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1972     ok( r == ERROR_SUCCESS, "wrong return val\n");
1973     ok( sz == 0, "wrong size returned\n");
1974
1975     check_prop_empty( hpkg, "boo");
1976     sz = 0;
1977     strcpy(buffer,"x");
1978     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1979     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1980     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1981     ok( sz == 0, "wrong size returned\n");
1982
1983     sz = 1;
1984     strcpy(buffer,"x");
1985     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1986     ok( r == ERROR_SUCCESS, "wrong return val\n");
1987     ok( buffer[0] == 0, "buffer was not changed\n");
1988     ok( sz == 0, "wrong size returned\n");
1989
1990     /* set the property to something */
1991     r = MsiSetProperty( 0, NULL, NULL );
1992     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1993
1994     r = MsiSetProperty( hpkg, NULL, NULL );
1995     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1996
1997     r = MsiSetProperty( hpkg, "", NULL );
1998     ok( r == ERROR_SUCCESS, "wrong return val\n");
1999
2000     /* try set and get some illegal property identifiers */
2001     r = MsiSetProperty( hpkg, "", "asdf" );
2002     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2003
2004     r = MsiSetProperty( hpkg, "=", "asdf" );
2005     ok( r == ERROR_SUCCESS, "wrong return val\n");
2006
2007     r = MsiSetProperty( hpkg, " ", "asdf" );
2008     ok( r == ERROR_SUCCESS, "wrong return val\n");
2009
2010     r = MsiSetProperty( hpkg, "'", "asdf" );
2011     ok( r == ERROR_SUCCESS, "wrong return val\n");
2012
2013     sz = sizeof buffer;
2014     buffer[0]=0;
2015     r = MsiGetProperty( hpkg, "'", buffer, &sz );
2016     ok( r == ERROR_SUCCESS, "wrong return val\n");
2017     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2018
2019     /* set empty values */
2020     r = MsiSetProperty( hpkg, "boo", NULL );
2021     ok( r == ERROR_SUCCESS, "wrong return val\n");
2022     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2023
2024     r = MsiSetProperty( hpkg, "boo", "" );
2025     ok( r == ERROR_SUCCESS, "wrong return val\n");
2026     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2027
2028     /* set a non-empty value */
2029     r = MsiSetProperty( hpkg, "boo", "xyz" );
2030     ok( r == ERROR_SUCCESS, "wrong return val\n");
2031
2032     sz = 1;
2033     strcpy(buffer,"x");
2034     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2035     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2036     ok( buffer[0] == 0, "buffer was not changed\n");
2037     ok( sz == 3, "wrong size returned\n");
2038
2039     sz = 4;
2040     strcpy(buffer,"x");
2041     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2042     ok( r == ERROR_SUCCESS, "wrong return val\n");
2043     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2044     ok( sz == 3, "wrong size returned\n");
2045
2046     sz = 3;
2047     strcpy(buffer,"x");
2048     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2049     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2050     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2051     ok( sz == 3, "wrong size returned\n");
2052
2053     r = MsiSetProperty(hpkg, "SourceDir", "foo");
2054     ok( r == ERROR_SUCCESS, "wrong return val\n");
2055
2056     sz = 4;
2057     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2058     ok( r == ERROR_SUCCESS, "wrong return val\n");
2059     ok( !strcmp(buffer,""), "buffer wrong\n");
2060     ok( sz == 0, "wrong size returned\n");
2061
2062     sz = 4;
2063     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2064     ok( r == ERROR_SUCCESS, "wrong return val\n");
2065     ok( !strcmp(buffer,""), "buffer wrong\n");
2066     ok( sz == 0, "wrong size returned\n");
2067
2068     sz = 4;
2069     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2070     ok( r == ERROR_SUCCESS, "wrong return val\n");
2071     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2072     ok( sz == 3, "wrong size returned\n");
2073
2074     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2075     ok( r == ERROR_SUCCESS, "wrong return val\n");
2076
2077     sz = 0;
2078     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2079     ok( r == ERROR_SUCCESS, "return wrong\n");
2080     ok( sz == 13, "size wrong (%d)\n", sz);
2081
2082     sz = 13;
2083     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2084     ok( r == ERROR_MORE_DATA, "return wrong\n");
2085     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2086
2087     r = MsiSetProperty(hpkg, "property", "value");
2088     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2089
2090     sz = 6;
2091     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2093     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2094
2095     r = MsiSetProperty(hpkg, "property", NULL);
2096     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2097
2098     sz = 6;
2099     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2101     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2102
2103     MsiCloseHandle( hpkg );
2104     DeleteFile(msifile);
2105 }
2106
2107 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2108 {
2109     MSIHANDLE hview, hrec;
2110     BOOL found;
2111     CHAR buffer[MAX_PATH];
2112     DWORD sz;
2113     UINT r;
2114
2115     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2116     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2117     r = MsiViewExecute(hview, 0);
2118     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2119
2120     found = FALSE;
2121     while (r == ERROR_SUCCESS && !found)
2122     {
2123         r = MsiViewFetch(hview, &hrec);
2124         if (r != ERROR_SUCCESS) break;
2125
2126         sz = MAX_PATH;
2127         r = MsiRecordGetString(hrec, 1, buffer, &sz);
2128         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2129         {
2130             sz = MAX_PATH;
2131             r = MsiRecordGetString(hrec, 2, buffer, &sz);
2132             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2133                 found = TRUE;
2134         }
2135
2136         MsiCloseHandle(hrec);
2137     }
2138
2139     MsiViewClose(hview);
2140     MsiCloseHandle(hview);
2141
2142     return found;
2143 }
2144
2145 static void test_property_table(void)
2146 {
2147     const char *query;
2148     UINT r;
2149     MSIHANDLE hpkg, hdb, hrec;
2150     char buffer[MAX_PATH], package[10];
2151     DWORD sz;
2152     BOOL found;
2153
2154     hdb = create_package_db();
2155     ok( hdb, "failed to create package\n");
2156
2157     r = package_from_db(hdb, &hpkg);
2158     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2159     {
2160         skip("Not enough rights to perform tests\n");
2161         DeleteFile(msifile);
2162         return;
2163     }
2164     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2165
2166     MsiCloseHandle(hdb);
2167
2168     hdb = MsiGetActiveDatabase(hpkg);
2169
2170     query = "CREATE TABLE `_Property` ( "
2171         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2172     r = run_query(hdb, query);
2173     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2174
2175     MsiCloseHandle(hdb);
2176     MsiCloseHandle(hpkg);
2177     DeleteFile(msifile);
2178
2179     hdb = create_package_db();
2180     ok( hdb, "failed to create package\n");
2181
2182     query = "CREATE TABLE `_Property` ( "
2183         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2184     r = run_query(hdb, query);
2185     ok(r == ERROR_SUCCESS, "failed to create table\n");
2186
2187     query = "ALTER `_Property` ADD `foo` INTEGER";
2188     r = run_query(hdb, query);
2189     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2190
2191     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2192     r = run_query(hdb, query);
2193     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2194
2195     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2196     r = run_query(hdb, query);
2197     ok(r == ERROR_SUCCESS, "failed to add column\n");
2198
2199     sprintf(package, "#%i", hdb);
2200     r = MsiOpenPackage(package, &hpkg);
2201     todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2202     if (r == ERROR_SUCCESS)
2203         MsiCloseHandle(hpkg);
2204
2205     r = MsiCloseHandle(hdb);
2206     ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2207
2208     hdb = create_package_db();
2209     ok (hdb, "failed to create package database\n");
2210
2211     r = create_property_table(hdb);
2212     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2213
2214     r = add_property_entry(hdb, "'prop', 'val'");
2215     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2216
2217     r = package_from_db(hdb, &hpkg);
2218     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2219
2220     MsiCloseHandle(hdb);
2221
2222     sz = MAX_PATH;
2223     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2224     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2225     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2226
2227     hdb = MsiGetActiveDatabase(hpkg);
2228
2229     found = find_prop_in_property(hdb, "prop", "val");
2230     ok(found, "prop should be in the _Property table\n");
2231
2232     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2233     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2234
2235     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2236     r = do_query(hdb, query, &hrec);
2237     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2238
2239     found = find_prop_in_property(hdb, "dantes", "mercedes");
2240     ok(found == FALSE, "dantes should not be in the _Property table\n");
2241
2242     sz = MAX_PATH;
2243     lstrcpy(buffer, "aaa");
2244     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2245     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2246     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2247
2248     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2249     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2250
2251     found = find_prop_in_property(hdb, "dantes", "mercedes");
2252     ok(found == TRUE, "dantes should be in the _Property table\n");
2253
2254     MsiCloseHandle(hdb);
2255     MsiCloseHandle(hpkg);
2256     DeleteFile(msifile);
2257 }
2258
2259 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2260 {
2261     MSIHANDLE htab = 0;
2262     UINT res;
2263
2264     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2265     if( res == ERROR_SUCCESS )
2266     {
2267         UINT r;
2268
2269         r = MsiViewExecute( htab, hrec );
2270         if( r != ERROR_SUCCESS )
2271         {
2272             res = r;
2273             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2274         }
2275
2276         r = MsiViewClose( htab );
2277         if( r != ERROR_SUCCESS )
2278             res = r;
2279
2280         r = MsiCloseHandle( htab );
2281         if( r != ERROR_SUCCESS )
2282             res = r;
2283     }
2284     return res;
2285 }
2286
2287 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2288 {
2289     return try_query_param( hdb, szQuery, 0 );
2290 }
2291
2292 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2293 {
2294     MSIHANDLE summary;
2295     UINT r;
2296
2297     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2298     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2299
2300     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2301     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2302
2303     r = MsiSummaryInfoPersist(summary);
2304     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2305
2306     MsiCloseHandle(summary);
2307 }
2308
2309 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2310 {
2311     MSIHANDLE summary;
2312     UINT r;
2313
2314     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2315     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2316
2317     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2318     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2319
2320     r = MsiSummaryInfoPersist(summary);
2321     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2322
2323     MsiCloseHandle(summary);
2324 }
2325
2326 static void test_msipackage(void)
2327 {
2328     MSIHANDLE hdb = 0, hpack = 100;
2329     UINT r;
2330     const char *query;
2331     char name[10];
2332
2333     /* NULL szPackagePath */
2334     r = MsiOpenPackage(NULL, &hpack);
2335     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2336
2337     /* empty szPackagePath */
2338     r = MsiOpenPackage("", &hpack);
2339     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2340     {
2341         skip("Not enough rights to perform tests\n");
2342         return;
2343     }
2344     todo_wine
2345     {
2346         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2347     }
2348
2349     if (r == ERROR_SUCCESS)
2350         MsiCloseHandle(hpack);
2351
2352     /* nonexistent szPackagePath */
2353     r = MsiOpenPackage("nonexistent", &hpack);
2354     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2355
2356     /* NULL hProduct */
2357     r = MsiOpenPackage(msifile, NULL);
2358     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2359
2360     name[0]='#';
2361     name[1]=0;
2362     r = MsiOpenPackage(name, &hpack);
2363     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2364
2365     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2366     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2367
2368     /* database exists, but is emtpy */
2369     sprintf(name, "#%d", hdb);
2370     r = MsiOpenPackage(name, &hpack);
2371     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2372        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2373
2374     query = "CREATE TABLE `Property` ( "
2375             "`Property` CHAR(72), `Value` CHAR(0) "
2376             "PRIMARY KEY `Property`)";
2377     r = try_query(hdb, query);
2378     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2379
2380     query = "CREATE TABLE `InstallExecuteSequence` ("
2381             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2382             "PRIMARY KEY `Action`)";
2383     r = try_query(hdb, query);
2384     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2385
2386     /* a few key tables exist */
2387     sprintf(name, "#%d", hdb);
2388     r = MsiOpenPackage(name, &hpack);
2389     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2390        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2391
2392     MsiCloseHandle(hdb);
2393     DeleteFile(msifile);
2394
2395     /* start with a clean database to show what constitutes a valid package */
2396     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2398
2399     sprintf(name, "#%d", hdb);
2400
2401     /* The following summary information props must exist:
2402      *  - PID_REVNUMBER
2403      *  - PID_PAGECOUNT
2404      */
2405
2406     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2407     r = MsiOpenPackage(name, &hpack);
2408     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2409        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2410
2411     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2412     r = MsiOpenPackage(name, &hpack);
2413     ok(r == ERROR_SUCCESS,
2414        "Expected ERROR_SUCCESS, got %d\n", r);
2415
2416     MsiCloseHandle(hpack);
2417     MsiCloseHandle(hdb);
2418     DeleteFile(msifile);
2419 }
2420
2421 static void test_formatrecord2(void)
2422 {
2423     MSIHANDLE hpkg, hrec ;
2424     char buffer[0x100];
2425     DWORD sz;
2426     UINT r;
2427
2428     r = package_from_db(create_package_db(), &hpkg);
2429     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2430     {
2431         skip("Not enough rights to perform tests\n");
2432         DeleteFile(msifile);
2433         return;
2434     }
2435     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2436
2437     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2438     ok( r == ERROR_SUCCESS, "set property failed\n");
2439
2440     hrec = MsiCreateRecord(2);
2441     ok(hrec, "create record failed\n");
2442
2443     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2444     ok( r == ERROR_SUCCESS, "format record failed\n");
2445
2446     buffer[0] = 0;
2447     sz = sizeof buffer;
2448     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2449
2450     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2451     r = MsiRecordSetString(hrec, 1, "hoo");
2452     sz = sizeof buffer;
2453     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2454     ok( sz == 3, "size wrong\n");
2455     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2456     ok( r == ERROR_SUCCESS, "format failed\n");
2457
2458     r = MsiRecordSetString(hrec, 0, "x[~]x");
2459     sz = sizeof buffer;
2460     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2461     ok( sz == 3, "size wrong\n");
2462     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2463     ok( r == ERROR_SUCCESS, "format failed\n");
2464
2465     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2466     r = MsiRecordSetString(hrec, 1, "hoo");
2467     sz = sizeof buffer;
2468     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2469     ok( sz == 3, "size wrong\n");
2470     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2471     ok( r == ERROR_SUCCESS, "format failed\n");
2472
2473     r = MsiRecordSetString(hrec, 0, "[\\[]");
2474     sz = sizeof buffer;
2475     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2476     ok( sz == 1, "size wrong\n");
2477     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2478     ok( r == ERROR_SUCCESS, "format failed\n");
2479
2480     SetEnvironmentVariable("FOO", "BAR");
2481     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2482     sz = sizeof buffer;
2483     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2484     ok( sz == 3, "size wrong\n");
2485     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2486     ok( r == ERROR_SUCCESS, "format failed\n");
2487
2488     r = MsiRecordSetString(hrec, 0, "[[1]]");
2489     r = MsiRecordSetString(hrec, 1, "%FOO");
2490     sz = sizeof buffer;
2491     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2492     ok( sz == 3, "size wrong\n");
2493     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2494     ok( r == ERROR_SUCCESS, "format failed\n");
2495
2496     MsiCloseHandle( hrec );
2497     MsiCloseHandle( hpkg );
2498     DeleteFile(msifile);
2499 }
2500
2501 static void test_states(void)
2502 {
2503     MSIHANDLE hpkg;
2504     UINT r;
2505     MSIHANDLE hdb;
2506     INSTALLSTATE state, action;
2507
2508     static const CHAR msifile2[] = "winetest2-package.msi";
2509     static const CHAR msifile3[] = "winetest3-package.msi";
2510     static const CHAR msifile4[] = "winetest4-package.msi";
2511
2512     if (is_process_limited())
2513     {
2514         skip("process is limited\n");
2515         return;
2516     }
2517
2518     hdb = create_package_db();
2519     ok ( hdb, "failed to create package database\n" );
2520
2521     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2522     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2523
2524     r = create_property_table( hdb );
2525     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2526
2527     r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2528     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2529
2530     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2531     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2532
2533     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2534     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2535
2536     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2537     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2538
2539     r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2540     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2541
2542     r = create_install_execute_sequence_table( hdb );
2543     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2544
2545     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2546     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2547
2548     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2549     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2550
2551     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2552     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2553
2554     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2555     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2556
2557     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2558     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2559
2560     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2561     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2562
2563     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2564     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2565
2566     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2567     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2568
2569     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2570     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2571
2572     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2573     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2574
2575     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2576     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2577
2578     r = create_media_table( hdb );
2579     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2580
2581     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2582     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2583
2584     r = create_feature_table( hdb );
2585     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2586
2587     r = create_component_table( hdb );
2588     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2589
2590     /* msidbFeatureAttributesFavorLocal */
2591     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2592     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2593
2594     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2595     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2596     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2597
2598     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2599     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2600     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2601
2602     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2603     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2604     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2605
2606     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2607     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2608     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2609
2610     /* msidbFeatureAttributesFavorSource */
2611     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2612     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2613
2614     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2615     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2616     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2617
2618     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2619     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2620     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2621
2622     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2623     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2624     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2625
2626     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2627     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2628     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2629
2630     /* msidbFeatureAttributesFavorSource */
2631     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2632     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2633
2634     /* msidbFeatureAttributesFavorLocal */
2635     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2636     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2637
2638     /* disabled */
2639     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2640     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2641
2642     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2643     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2644     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2645
2646     /* no feature parent:msidbComponentAttributesLocalOnly */
2647     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2648     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2649
2650     /* msidbFeatureAttributesFavorLocal:removed */
2651     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2652     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2653
2654     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2655     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2656     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2657
2658     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2659     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2660     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2661
2662     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2663     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2664     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2665
2666     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2667     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2668     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2669
2670     /* msidbFeatureAttributesFavorSource:removed */
2671     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2672     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2673
2674     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2675     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2676     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2677
2678     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2679     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2680     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2681
2682     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2683     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2684     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2685
2686     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2687     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2688     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2689
2690     /* msidbFeatureAttributesFavorLocal */
2691     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2692     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2693
2694     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2695     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2696
2697     /* msidbFeatureAttributesFavorSource */
2698     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2699     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2700
2701     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2702     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2703
2704     /* msidbFeatureAttributesFavorAdvertise */
2705     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2706     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2707
2708     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2709     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2710
2711     /* msidbFeatureAttributesUIDisallowAbsent */
2712     r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2713     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2714
2715     r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2716     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2717
2718     r = create_feature_components_table( hdb );
2719     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2720
2721     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2722     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2723
2724     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2725     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2726
2727     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2728     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2729
2730     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2731     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2732
2733     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2734     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2735
2736     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2737     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2738
2739     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2740     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2741
2742     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2743     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2744
2745     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2746     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2747
2748     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2749     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2750
2751     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2752     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2753
2754     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2755     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2756
2757     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2758     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2759
2760     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2761     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2762
2763     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2764     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2765
2766     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2767     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2768
2769     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2770     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2771
2772     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2773     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2774
2775     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2776     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2777
2778     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2779     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2780
2781     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2782     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2783
2784     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2785     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2786
2787     r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2788     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2789
2790     r = create_file_table( hdb );
2791     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2792
2793     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2794     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2795
2796     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2797     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2798
2799     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2800     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2801
2802     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2803     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2804
2805     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2806     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2807
2808     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2809     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2810
2811     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2812     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2813
2814     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2815     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2816
2817     /* compressed file */
2818     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2819     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2820
2821     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2822     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2823
2824     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2825     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2826
2827     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2828     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2829
2830     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2831     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2832
2833     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2834     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2835
2836     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2837     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2838
2839     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2840     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2841
2842     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2843     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2844
2845     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2846     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2847
2848     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2849     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2850
2851     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2852     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2853
2854     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2855     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2856
2857     r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
2858     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2859
2860     MsiDatabaseCommit(hdb);
2861
2862     /* these properties must not be in the saved msi file */
2863     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2864     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2865
2866     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2867     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2868
2869     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2870     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2871
2872     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2873     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2874
2875     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2876     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2877
2878     r = package_from_db( hdb, &hpkg );
2879     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2880     {
2881         skip("Not enough rights to perform tests\n");
2882         DeleteFile(msifile);
2883         return;
2884     }
2885     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2886
2887     MsiCloseHandle(hdb);
2888
2889     CopyFileA(msifile, msifile2, FALSE);
2890     CopyFileA(msifile, msifile3, FALSE);
2891     CopyFileA(msifile, msifile4, FALSE);
2892
2893     state = 0xdeadbee;
2894     action = 0xdeadbee;
2895     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2896     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2897     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2898     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2899
2900     state = 0xdeadbee;
2901     action = 0xdeadbee;
2902     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2903     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2904     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2905     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2906
2907     state = 0xdeadbee;
2908     action = 0xdeadbee;
2909     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2910     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2911     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2912     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2913
2914     state = 0xdeadbee;
2915     action = 0xdeadbee;
2916     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2917     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2918     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2919     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2920
2921     state = 0xdeadbee;
2922     action = 0xdeadbee;
2923     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2924     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2925     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2926     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2927
2928     state = 0xdeadbee;
2929     action = 0xdeadbee;
2930     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2931     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2932     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2933     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2934
2935     state = 0xdeadbee;
2936     action = 0xdeadbee;
2937     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2938     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2939     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2940     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2941
2942     state = 0xdeadbee;
2943     action = 0xdeadbee;
2944     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2945     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2946     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2947     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2948
2949     state = 0xdeadbee;
2950     action = 0xdeadbee;
2951     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2952     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2953     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2954     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2955
2956     state = 0xdeadbee;
2957     action = 0xdeadbee;
2958     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2959     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2960     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2961     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2962
2963     state = 0xdeadbee;
2964     action = 0xdeadbee;
2965     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
2966     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2967     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2968     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2969
2970     state = 0xdeadbee;
2971     action = 0xdeadbee;
2972     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2973     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2974     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2975     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2976
2977     state = 0xdeadbee;
2978     action = 0xdeadbee;
2979     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2980     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2981     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2982     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2983
2984     state = 0xdeadbee;
2985     action = 0xdeadbee;
2986     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2987     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2988     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2989     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2990
2991     state = 0xdeadbee;
2992     action = 0xdeadbee;
2993     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2994     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2995     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2996     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2997
2998     state = 0xdeadbee;
2999     action = 0xdeadbee;
3000     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3001     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3002     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3003     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3004
3005     state = 0xdeadbee;
3006     action = 0xdeadbee;
3007     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3008     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3009     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3010     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3011
3012     state = 0xdeadbee;
3013     action = 0xdeadbee;
3014     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3015     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3016     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3017     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3018
3019     state = 0xdeadbee;
3020     action = 0xdeadbee;
3021     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3022     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3023     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3024     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3025
3026     state = 0xdeadbee;
3027     action = 0xdeadbee;
3028     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3029     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3030     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3031     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3032
3033     state = 0xdeadbee;
3034     action = 0xdeadbee;
3035     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3036     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3037     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3038     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3039
3040     state = 0xdeadbee;
3041     action = 0xdeadbee;
3042     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3043     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3044     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3045     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3046
3047     state = 0xdeadbee;
3048     action = 0xdeadbee;
3049     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3050     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3051     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3052     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3053
3054     state = 0xdeadbee;
3055     action = 0xdeadbee;
3056     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3057     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3058     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3059     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3060
3061     state = 0xdeadbee;
3062     action = 0xdeadbee;
3063     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3064     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3065     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3066     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3067
3068     state = 0xdeadbee;
3069     action = 0xdeadbee;
3070     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3071     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3072     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3073     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3074
3075     state = 0xdeadbee;
3076     action = 0xdeadbee;
3077     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3078     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3079     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3080     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3081
3082     state = 0xdeadbee;
3083     action = 0xdeadbee;
3084     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3085     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3086     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3087     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3088
3089     state = 0xdeadbee;
3090     action = 0xdeadbee;
3091     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3092     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3093     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3094     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3095
3096     state = 0xdeadbee;
3097     action = 0xdeadbee;
3098     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3099     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3100     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3101     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3102
3103     state = 0xdeadbee;
3104     action = 0xdeadbee;
3105     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3106     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3107     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3108     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3109
3110     state = 0xdeadbee;
3111     action = 0xdeadbee;
3112     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3113     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3114     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3115     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3116
3117     state = 0xdeadbee;
3118     action = 0xdeadbee;
3119     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3120     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3121     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3122     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3123
3124     r = MsiDoAction( hpkg, "CostInitialize");
3125     ok( r == ERROR_SUCCESS, "cost init failed\n");
3126
3127     state = 0xdeadbee;
3128     action = 0xdeadbee;
3129     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3130     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3131     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3132     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3133
3134     state = 0xdeadbee;
3135     action = 0xdeadbee;
3136     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3137     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3138     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3139     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3140
3141     state = 0xdeadbee;
3142     action = 0xdeadbee;
3143     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3144     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3145     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3146     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3147
3148     state = 0xdeadbee;
3149     action = 0xdeadbee;
3150     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3152     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3153     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3154
3155     state = 0xdeadbee;
3156     action = 0xdeadbee;
3157     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3159     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3160     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3161
3162     state = 0xdeadbee;
3163     action = 0xdeadbee;
3164     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3166     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3167     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3168
3169     state = 0xdeadbee;
3170     action = 0xdeadbee;
3171     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3172     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3173     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3174     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3175
3176     state = 0xdeadbee;
3177     action = 0xdeadbee;
3178     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3179     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3180     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3181     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3182
3183     state = 0xdeadbee;
3184     action = 0xdeadbee;
3185     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3186     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3187     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3188     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3189
3190     state = 0xdeadbee;
3191     action = 0xdeadbee;
3192     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3193     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3194     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3195     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3196
3197     state = 0xdeadbee;
3198     action = 0xdeadbee;
3199     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3201     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3202     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3203
3204     state = 0xdeadbee;
3205     action = 0xdeadbee;
3206     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3208     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3209     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3210
3211     state = 0xdeadbee;
3212     action = 0xdeadbee;
3213     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3215     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3216     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3217
3218     state = 0xdeadbee;
3219     action = 0xdeadbee;
3220     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3222     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3223     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3224
3225     state = 0xdeadbee;
3226     action = 0xdeadbee;
3227     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3228     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3229     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3230     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3231
3232     state = 0xdeadbee;
3233     action = 0xdeadbee;
3234     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3235     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3236     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3237     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3238
3239     state = 0xdeadbee;
3240     action = 0xdeadbee;
3241     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3243     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3244     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3245
3246     state = 0xdeadbee;
3247     action = 0xdeadbee;
3248     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3249     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3250     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3251     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3252
3253     state = 0xdeadbee;
3254     action = 0xdeadbee;
3255     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3256     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3257     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3258     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3259
3260     state = 0xdeadbee;
3261     action = 0xdeadbee;
3262     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3263     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3264     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3265     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3266
3267     state = 0xdeadbee;
3268     action = 0xdeadbee;
3269     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3270     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3271     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3272     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3273
3274     state = 0xdeadbee;
3275     action = 0xdeadbee;
3276     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3277     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3278     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3279     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3280
3281     state = 0xdeadbee;
3282     action = 0xdeadbee;
3283     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3284     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3285     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3286     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3287
3288     state = 0xdeadbee;
3289     action = 0xdeadbee;
3290     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3291     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3292     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3293     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3294
3295     state = 0xdeadbee;
3296     action = 0xdeadbee;
3297     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3298     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3299     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3300     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3301
3302     state = 0xdeadbee;
3303     action = 0xdeadbee;
3304     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3305     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3306     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3307     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3308
3309     state = 0xdeadbee;
3310     action = 0xdeadbee;
3311     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3312     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3313     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3314     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3315
3316     state = 0xdeadbee;
3317     action = 0xdeadbee;
3318     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3319     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3320     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3321     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3322
3323     state = 0xdeadbee;
3324     action = 0xdeadbee;
3325     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3326     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3327     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3328     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3329
3330     state = 0xdeadbee;
3331     action = 0xdeadbee;
3332     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3333     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3334     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3335     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3336
3337     state = 0xdeadbee;
3338     action = 0xdeadbee;
3339     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3340     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3341     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3342     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3343
3344     state = 0xdeadbee;
3345     action = 0xdeadbee;
3346     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3347     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3348     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3349     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3350
3351     state = 0xdeadbee;
3352     action = 0xdeadbee;
3353     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3354     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3355     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3356     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3357
3358     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3359
3360     r = MsiDoAction( hpkg, "FileCost");
3361     ok( r == ERROR_SUCCESS, "file cost failed\n");
3362
3363     r = MsiGetFeatureState(hpkg, "one", NULL, NULL);
3364     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3365
3366     action = 0xdeadbee;
3367     r = MsiGetFeatureState(hpkg, "one", NULL, &action);
3368     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3369     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3370
3371     state = 0xdeadbee;
3372     r = MsiGetFeatureState( hpkg, "one", &state, NULL);
3373     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3374     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3375
3376     state = 0xdeadbee;
3377     action = 0xdeadbee;
3378     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3379     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3380     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3381     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3382
3383     state = 0xdeadbee;
3384     action = 0xdeadbee;
3385     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3386     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3387     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3388     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3389
3390     state = 0xdeadbee;
3391     action = 0xdeadbee;
3392     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3393     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3394     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3395     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3396
3397     state = 0xdeadbee;
3398     action = 0xdeadbee;
3399     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3400     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3401     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3402     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3403
3404     state = 0xdeadbee;
3405     action = 0xdeadbee;
3406     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3407     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3408     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3409     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3410
3411     state = 0xdeadbee;
3412     action = 0xdeadbee;
3413     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3414     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3415     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3416     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3417
3418     state = 0xdeadbee;
3419     action = 0xdeadbee;
3420     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3421     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3422     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3423     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3424
3425     state = 0xdeadbee;
3426     action = 0xdeadbee;
3427     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3428     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3429     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3430     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3431
3432     state = 0xdeadbee;
3433     action = 0xdeadbee;
3434     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3435     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3436     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3437     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3438
3439     state = 0xdeadbee;
3440     action = 0xdeadbee;
3441     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3442     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3443     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3444     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3445
3446     state = 0xdeadbee;
3447     action = 0xdeadbee;
3448     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3449     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3450     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3451     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3452
3453     state = 0xdeadbee;
3454     action = 0xdeadbee;
3455     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3457     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3458     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3459
3460     state = 0xdeadbee;
3461     action = 0xdeadbee;
3462     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3464     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3465     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3466
3467     state = 0xdeadbee;
3468     action = 0xdeadbee;
3469     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3471     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3472     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3473
3474     state = 0xdeadbee;
3475     action = 0xdeadbee;
3476     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3478     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3479     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3480
3481     state = 0xdeadbee;
3482     action = 0xdeadbee;
3483     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3485     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3486     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3487
3488     state = 0xdeadbee;
3489     action = 0xdeadbee;
3490     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3492     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3493     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3494
3495     state = 0xdeadbee;
3496     action = 0xdeadbee;
3497     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3499     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3500     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3501
3502     state = 0xdeadbee;
3503     action = 0xdeadbee;
3504     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3505     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3506     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3507     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3508
3509     state = 0xdeadbee;
3510     action = 0xdeadbee;
3511     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3513     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3514     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3515
3516     state = 0xdeadbee;
3517     action = 0xdeadbee;
3518     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3520     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3521     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3522
3523     state = 0xdeadbee;
3524     action = 0xdeadbee;
3525     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3527     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3528     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3529
3530     state = 0xdeadbee;
3531     action = 0xdeadbee;
3532     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3534     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3535     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3536
3537     state = 0xdeadbee;
3538     action = 0xdeadbee;
3539     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3541     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3542     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3543
3544     state = 0xdeadbee;
3545     action = 0xdeadbee;
3546     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3548     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3549     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3550
3551     state = 0xdeadbee;
3552     action = 0xdeadbee;
3553     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3555     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3556     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3557
3558     state = 0xdeadbee;
3559     action = 0xdeadbee;
3560     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3562     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3563     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3564
3565     state = 0xdeadbee;
3566     action = 0xdeadbee;
3567     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3569     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3570     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3571
3572     state = 0xdeadbee;
3573     action = 0xdeadbee;
3574     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3576     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3577     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3578
3579     state = 0xdeadbee;
3580     action = 0xdeadbee;
3581     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3583     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3584     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3585
3586     state = 0xdeadbee;
3587     action = 0xdeadbee;
3588     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3590     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3591     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3592
3593     state = 0xdeadbee;
3594     action = 0xdeadbee;
3595     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3597     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3598     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3599
3600     state = 0xdeadbee;
3601     action = 0xdeadbee;
3602     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3604     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3605     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3606
3607     r = MsiDoAction( hpkg, "CostFinalize");
3608     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3609
3610     state = 0xdeadbee;
3611     action = 0xdeadbee;
3612     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3613     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3614     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3615     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3616
3617     state = 0xdeadbee;
3618     action = 0xdeadbee;
3619     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3620     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3621     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3622     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3623
3624     state = 0xdeadbee;
3625     action = 0xdeadbee;
3626     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3627     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3628     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3629     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3630
3631     state = 0xdeadbee;
3632     action = 0xdeadbee;
3633     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3635     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3636     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3637
3638     state = 0xdeadbee;
3639     action = 0xdeadbee;
3640     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3641     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3642     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3643     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3644
3645     state = 0xdeadbee;
3646     action = 0xdeadbee;
3647     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3648     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3649     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3650     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3651
3652     state = 0xdeadbee;
3653     action = 0xdeadbee;
3654     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3655     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3656     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3657     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3658
3659     state = 0xdeadbee;
3660     action = 0xdeadbee;
3661     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3663     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3664     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3665
3666     state = 0xdeadbee;
3667     action = 0xdeadbee;
3668     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3669     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3670     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3671     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3672
3673     state = 0xdeadbee;
3674     action = 0xdeadbee;
3675     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3676     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3677     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3678     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3679
3680     state = 0xdeadbee;
3681     action = 0xdeadbee;
3682     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3683     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3684     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3685     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3686
3687     state = 0xdeadbee;
3688     action = 0xdeadbee;
3689     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3690     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3691     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3692     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3693
3694     state = 0xdeadbee;
3695     action = 0xdeadbee;
3696     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3697     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3698     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3699     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3700
3701     state = 0xdeadbee;
3702     action = 0xdeadbee;
3703     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3705     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3706     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3707
3708     state = 0xdeadbee;
3709     action = 0xdeadbee;
3710     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3712     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3713     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3714
3715     state = 0xdeadbee;
3716     action = 0xdeadbee;
3717     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3718     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3719     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3720     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3721
3722     state = 0xdeadbee;
3723     action = 0xdeadbee;
3724     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3725     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3726     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3727     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3728
3729     state = 0xdeadbee;
3730     action = 0xdeadbee;
3731     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3732     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3733     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3734     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3735
3736     state = 0xdeadbee;
3737     action = 0xdeadbee;
3738     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3739     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3740     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3741     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3742
3743     state = 0xdeadbee;
3744     action = 0xdeadbee;
3745     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3746     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3747     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3748     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3749
3750     state = 0xdeadbee;
3751     action = 0xdeadbee;
3752     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3753     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3754     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3755     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3756
3757     state = 0xdeadbee;
3758     action = 0xdeadbee;
3759     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3760     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3761     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3762     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3763
3764     state = 0xdeadbee;
3765     action = 0xdeadbee;
3766     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3767     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3768     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3769     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3770
3771     state = 0xdeadbee;
3772     action = 0xdeadbee;
3773     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3774     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3775     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3776     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3777
3778     state = 0xdeadbee;
3779     action = 0xdeadbee;
3780     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3781     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3782     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3783     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3784
3785     state = 0xdeadbee;
3786     action = 0xdeadbee;
3787     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3788     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3789     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3790     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3791
3792     state = 0xdeadbee;
3793     action = 0xdeadbee;
3794     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3795     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3796     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3797     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3798
3799     state = 0xdeadbee;
3800     action = 0xdeadbee;
3801     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3802     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3803     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3804     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3805
3806     state = 0xdeadbee;
3807     action = 0xdeadbee;
3808     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3809     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3810     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3811     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3812
3813     state = 0xdeadbee;
3814     action = 0xdeadbee;
3815     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3816     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3817     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3818     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3819
3820     state = 0xdeadbee;
3821     action = 0xdeadbee;
3822     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3823     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3824     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3825     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3826
3827     state = 0xdeadbee;
3828     action = 0xdeadbee;
3829     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3830     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3831     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3832     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3833
3834     state = 0xdeadbee;
3835     action = 0xdeadbee;
3836     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3837     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3838     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3839     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3840
3841     MsiCloseHandle( hpkg );
3842
3843     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3844
3845     /* publish the features and components */
3846     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3847     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3848
3849     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3850     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3851
3852     /* these properties must not be in the saved msi file */
3853     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3854     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3855
3856     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3857     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3858
3859     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3860     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3861
3862     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3863     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3864
3865     r = package_from_db( hdb, &hpkg );
3866     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3867
3868     MsiCloseHandle(hdb);
3869
3870     state = 0xdeadbee;
3871     action = 0xdeadbee;
3872     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3873     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3874     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3875     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3876
3877     state = 0xdeadbee;
3878     action = 0xdeadbee;
3879     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3880     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3881     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3882     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3883
3884     state = 0xdeadbee;
3885     action = 0xdeadbee;
3886     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3887     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3888     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3889     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3890
3891     state = 0xdeadbee;
3892     action = 0xdeadbee;
3893     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3894     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3895     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3896     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3897
3898     state = 0xdeadbee;
3899     action = 0xdeadbee;
3900     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3901     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3902     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3903     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3904
3905     state = 0xdeadbee;
3906     action = 0xdeadbee;
3907     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3908     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3909     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3910     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3911
3912     state = 0xdeadbee;
3913     action = 0xdeadbee;
3914     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3915     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3916     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3917     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3918
3919     state = 0xdeadbee;
3920     action = 0xdeadbee;
3921     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3922     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3923     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3924     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3925
3926     state = 0xdeadbee;
3927     action = 0xdeadbee;
3928     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3929     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3930     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3931     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3932
3933     state = 0xdeadbee;
3934     action = 0xdeadbee;
3935     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3936     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3937     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3938     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3939
3940     state = 0xdeadbee;
3941     action = 0xdeadbee;
3942     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3943     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3944     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3945     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3946
3947     state = 0xdeadbee;
3948     action = 0xdeadbee;
3949     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3950     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3951     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3952     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3953
3954     state = 0xdeadbee;
3955     action = 0xdeadbee;
3956     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3957     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3958     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3959     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3960
3961     state = 0xdeadbee;
3962     action = 0xdeadbee;
3963     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3964     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3965     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3966     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3967
3968     state = 0xdeadbee;
3969     action = 0xdeadbee;
3970     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3971     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3972     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3973     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3974
3975     state = 0xdeadbee;
3976     action = 0xdeadbee;
3977     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3978     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3979     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3980     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3981
3982     state = 0xdeadbee;
3983     action = 0xdeadbee;
3984     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3985     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3986     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3987     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3988
3989     state = 0xdeadbee;
3990     action = 0xdeadbee;
3991     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3992     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3993     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3994     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3995
3996     state = 0xdeadbee;
3997     action = 0xdeadbee;
3998     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3999     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4000     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4001     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4002
4003     state = 0xdeadbee;
4004     action = 0xdeadbee;
4005     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4006     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4007     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4008     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4009
4010     state = 0xdeadbee;
4011     action = 0xdeadbee;
4012     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4013     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4014     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4015     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4016
4017     state = 0xdeadbee;
4018     action = 0xdeadbee;
4019     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4020     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4021     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4022     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4023
4024     state = 0xdeadbee;
4025     action = 0xdeadbee;
4026     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4027     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4028     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4029     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4030
4031     state = 0xdeadbee;
4032     action = 0xdeadbee;
4033     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4034     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4035     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4036     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4037
4038     state = 0xdeadbee;
4039     action = 0xdeadbee;
4040     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4041     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4042     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4043     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4044
4045     state = 0xdeadbee;
4046     action = 0xdeadbee;
4047     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4048     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4049     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4050     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4051
4052     state = 0xdeadbee;
4053     action = 0xdeadbee;
4054     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4055     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4056     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4057     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4058
4059     state = 0xdeadbee;
4060     action = 0xdeadbee;
4061     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4062     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4063     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4064     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4065
4066     state = 0xdeadbee;
4067     action = 0xdeadbee;
4068     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4069     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4070     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4071     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4072
4073     state = 0xdeadbee;
4074     action = 0xdeadbee;
4075     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4076     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4077     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4078     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4079
4080     state = 0xdeadbee;
4081     action = 0xdeadbee;
4082     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4083     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4084     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4085     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4086
4087     state = 0xdeadbee;
4088     action = 0xdeadbee;
4089     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4090     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4091     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4092     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4093
4094     state = 0xdeadbee;
4095     action = 0xdeadbee;
4096     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4097     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4098     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4099     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4100
4101     r = MsiDoAction( hpkg, "CostInitialize");
4102     ok( r == ERROR_SUCCESS, "cost init failed\n");
4103
4104     state = 0xdeadbee;
4105     action = 0xdeadbee;
4106     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4108     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4109     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4110
4111     state = 0xdeadbee;
4112     action = 0xdeadbee;
4113     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4115     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4116     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4117
4118     state = 0xdeadbee;
4119     action = 0xdeadbee;
4120     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4122     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4123     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4124
4125     state = 0xdeadbee;
4126     action = 0xdeadbee;
4127     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4129     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4130     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4131
4132     state = 0xdeadbee;
4133     action = 0xdeadbee;
4134     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4136     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4137     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4138
4139     state = 0xdeadbee;
4140     action = 0xdeadbee;
4141     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4143     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4144     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4145
4146     state = 0xdeadbee;
4147     action = 0xdeadbee;
4148     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4150     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4151     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4152
4153     state = 0xdeadbee;
4154     action = 0xdeadbee;
4155     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4157     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4158     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4159
4160     state = 0xdeadbee;
4161     action = 0xdeadbee;
4162     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4164     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4165     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4166
4167     state = 0xdeadbee;
4168     action = 0xdeadbee;
4169     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4171     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4172     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4173
4174     state = 0xdeadbee;
4175     action = 0xdeadbee;
4176     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4177     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4178     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4179     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4180
4181     state = 0xdeadbee;
4182     action = 0xdeadbee;
4183     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4184     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4185     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4186     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4187
4188     state = 0xdeadbee;
4189     action = 0xdeadbee;
4190     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4191     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4192     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4193     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4194
4195     state = 0xdeadbee;
4196     action = 0xdeadbee;
4197     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4198     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4199     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4200     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4201
4202     state = 0xdeadbee;
4203     action = 0xdeadbee;
4204     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4205     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4206     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4207     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4208
4209     state = 0xdeadbee;
4210     action = 0xdeadbee;
4211     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4212     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4213     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4214     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4215
4216     state = 0xdeadbee;
4217     action = 0xdeadbee;
4218     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4219     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4220     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4221     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4222
4223     state = 0xdeadbee;
4224     action = 0xdeadbee;
4225     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4226     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4227     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4228     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4229
4230     state = 0xdeadbee;
4231     action = 0xdeadbee;
4232     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4233     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4234     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4235     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4236
4237     state = 0xdeadbee;
4238     action = 0xdeadbee;
4239     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4240     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4241     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4242     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4243
4244     state = 0xdeadbee;
4245     action = 0xdeadbee;
4246     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4247     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4248     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4249     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4250
4251     state = 0xdeadbee;
4252     action = 0xdeadbee;
4253     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4254     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4255     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4256     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4257
4258     state = 0xdeadbee;
4259     action = 0xdeadbee;
4260     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4261     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4262     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4263     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4264
4265     state = 0xdeadbee;
4266     action = 0xdeadbee;
4267     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4268     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4269     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4270     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4271
4272     state = 0xdeadbee;
4273     action = 0xdeadbee;
4274     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4275     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4276     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4277     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4278
4279     state = 0xdeadbee;
4280     action = 0xdeadbee;
4281     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4282     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4283     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4284     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4285
4286     state = 0xdeadbee;
4287     action = 0xdeadbee;
4288     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4289     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4290     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4291     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4292
4293     state = 0xdeadbee;
4294     action = 0xdeadbee;
4295     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4296     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4297     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4298     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4299
4300     state = 0xdeadbee;
4301     action = 0xdeadbee;
4302     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4303     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4304     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4305     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4306
4307     state = 0xdeadbee;
4308     action = 0xdeadbee;
4309     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4310     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4311     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4312     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4313
4314     state = 0xdeadbee;
4315     action = 0xdeadbee;
4316     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4317     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4318     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4319     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4320
4321     state = 0xdeadbee;
4322     action = 0xdeadbee;
4323     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4324     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4325     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4326     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4327
4328     state = 0xdeadbee;
4329     action = 0xdeadbee;
4330     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4331     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4332     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4333     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4334
4335     r = MsiDoAction( hpkg, "FileCost");
4336     ok( r == ERROR_SUCCESS, "file cost failed\n");
4337
4338     state = 0xdeadbee;
4339     action = 0xdeadbee;
4340     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
4367     action = 0xdeadbee;
4368     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4369     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4370     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4371     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4372
4373     state = 0xdeadbee;
4374     action = 0xdeadbee;
4375     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4376     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4377     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4378     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4379
4380     state = 0xdeadbee;
4381     action = 0xdeadbee;
4382     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4383     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4384     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4385     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4386
4387     state = 0xdeadbee;
4388     action = 0xdeadbee;
4389     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4390     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4391     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4392     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4393
4394     state = 0xdeadbee;
4395     action = 0xdeadbee;
4396     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4397     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4398     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4399     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4400
4401     state = 0xdeadbee;
4402     action = 0xdeadbee;
4403     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4406     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4407
4408     state = 0xdeadbee;
4409     action = 0xdeadbee;
4410     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4411     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4412     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4413     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4414
4415     state = 0xdeadbee;
4416     action = 0xdeadbee;
4417     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4418     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4419     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4420     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4421
4422     state = 0xdeadbee;
4423     action = 0xdeadbee;
4424     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4425     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4426     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4427     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4428
4429     state = 0xdeadbee;
4430     action = 0xdeadbee;
4431     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4432     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4433     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4434     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4435
4436     state = 0xdeadbee;
4437     action = 0xdeadbee;
4438     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4439     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4440     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4441     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4442
4443     state = 0xdeadbee;
4444     action = 0xdeadbee;
4445     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4446     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4447     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4448     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4449
4450     state = 0xdeadbee;
4451     action = 0xdeadbee;
4452     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4453     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4454     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4455     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4456
4457     state = 0xdeadbee;
4458     action = 0xdeadbee;
4459     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4460     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4461     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4462     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4463
4464     state = 0xdeadbee;
4465     action = 0xdeadbee;
4466     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4468     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4469     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4470
4471     state = 0xdeadbee;
4472     action = 0xdeadbee;
4473     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4475     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4476     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4477
4478     state = 0xdeadbee;
4479     action = 0xdeadbee;
4480     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4482     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4483     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4484
4485     state = 0xdeadbee;
4486     action = 0xdeadbee;
4487     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4489     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4490     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4491
4492     state = 0xdeadbee;
4493     action = 0xdeadbee;
4494     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4495     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4496     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4497     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4498
4499     state = 0xdeadbee;
4500     action = 0xdeadbee;
4501     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4502     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4503     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4504     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4505
4506     state = 0xdeadbee;
4507     action = 0xdeadbee;
4508     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4509     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4510     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4511     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4512
4513     state = 0xdeadbee;
4514     action = 0xdeadbee;
4515     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4516     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4517     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4518     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4519
4520     state = 0xdeadbee;
4521     action = 0xdeadbee;
4522     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4523     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4524     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4525     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4526
4527     state = 0xdeadbee;
4528     action = 0xdeadbee;
4529     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4530     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4531     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4532     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4533
4534     state = 0xdeadbee;
4535     action = 0xdeadbee;
4536     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4537     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4538     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4539     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4540
4541     state = 0xdeadbee;
4542     action = 0xdeadbee;
4543     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4544     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4545     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4546     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4547
4548     state = 0xdeadbee;
4549     action = 0xdeadbee;
4550     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4551     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4552     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4553     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4554
4555     r = MsiDoAction( hpkg, "CostFinalize");
4556     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4557
4558     state = 0xdeadbee;
4559     action = 0xdeadbee;
4560     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4562     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4563     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4564
4565     state = 0xdeadbee;
4566     action = 0xdeadbee;
4567     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4569     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4570     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4571
4572     state = 0xdeadbee;
4573     action = 0xdeadbee;
4574     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4576     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4577     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4578
4579     state = 0xdeadbee;
4580     action = 0xdeadbee;
4581     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4583     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4584     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4585
4586     state = 0xdeadbee;
4587     action = 0xdeadbee;
4588     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4590     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4591     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4592
4593     state = 0xdeadbee;
4594     action = 0xdeadbee;
4595     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4597     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4598     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4599
4600     state = 0xdeadbee;
4601     action = 0xdeadbee;
4602     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4604     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4605     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4606
4607     state = 0xdeadbee;
4608     action = 0xdeadbee;
4609     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4611     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4612     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4613
4614     state = 0xdeadbee;
4615     action = 0xdeadbee;
4616     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4618     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4619     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4620
4621     state = 0xdeadbee;
4622     action = 0xdeadbee;
4623     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4625     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4626     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4627
4628     state = 0xdeadbee;
4629     action = 0xdeadbee;
4630     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4632     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4633     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4634
4635     state = 0xdeadbee;
4636     action = 0xdeadbee;
4637     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4639     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4640     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4641
4642     state = 0xdeadbee;
4643     action = 0xdeadbee;
4644     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4645     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4646     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4647     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4648
4649     state = 0xdeadbee;
4650     action = 0xdeadbee;
4651     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4653     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4654     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4655
4656     state = 0xdeadbee;
4657     action = 0xdeadbee;
4658     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4660     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4661     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4662
4663     state = 0xdeadbee;
4664     action = 0xdeadbee;
4665     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4667     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4668     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4669
4670     state = 0xdeadbee;
4671     action = 0xdeadbee;
4672     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4674     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4675     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4676
4677     state = 0xdeadbee;
4678     action = 0xdeadbee;
4679     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4681     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4682     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4683
4684     state = 0xdeadbee;
4685     action = 0xdeadbee;
4686     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4688     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4689     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4690
4691     state = 0xdeadbee;
4692     action = 0xdeadbee;
4693     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4695     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4696     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4697
4698     state = 0xdeadbee;
4699     action = 0xdeadbee;
4700     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4701     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4702     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4703     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4704
4705     state = 0xdeadbee;
4706     action = 0xdeadbee;
4707     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4708     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4709     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4710     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4711
4712     state = 0xdeadbee;
4713     action = 0xdeadbee;
4714     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4715     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4716     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4717     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4718
4719     state = 0xdeadbee;
4720     action = 0xdeadbee;
4721     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4722     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4723     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4724     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4725
4726     state = 0xdeadbee;
4727     action = 0xdeadbee;
4728     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4729     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4730     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4731     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4732
4733     state = 0xdeadbee;
4734     action = 0xdeadbee;
4735     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4736     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4737     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4738     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4739
4740     state = 0xdeadbee;
4741     action = 0xdeadbee;
4742     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4743     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4744     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4745     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4746
4747     state = 0xdeadbee;
4748     action = 0xdeadbee;
4749     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4750     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4751     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4752     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4753
4754     state = 0xdeadbee;
4755     action = 0xdeadbee;
4756     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4757     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4758     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4759     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4760
4761     state = 0xdeadbee;
4762     action = 0xdeadbee;
4763     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4764     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4765     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4766     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4767
4768     state = 0xdeadbee;
4769     action = 0xdeadbee;
4770     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4771     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4772     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4773     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4774
4775     state = 0xdeadbee;
4776     action = 0xdeadbee;
4777     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4778     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4779     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4780     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4781
4782     state = 0xdeadbee;
4783     action = 0xdeadbee;
4784     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4785     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4786     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4787     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4788
4789     MsiCloseHandle(hpkg);
4790
4791     /* uninstall the product */
4792     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4793     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4794
4795     /* all features installed locally */
4796     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4797     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4798
4799     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4800     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4801
4802     /* these properties must not be in the saved msi file */
4803     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4804     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4805
4806     r = package_from_db( hdb, &hpkg );
4807     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
4808
4809     state = 0xdeadbee;
4810     action = 0xdeadbee;
4811     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4812     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4813     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4814     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4815
4816     state = 0xdeadbee;
4817     action = 0xdeadbee;
4818     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4819     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4820     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4821     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4822
4823     state = 0xdeadbee;
4824     action = 0xdeadbee;
4825     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4826     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4827     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4828     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4829
4830     state = 0xdeadbee;
4831     action = 0xdeadbee;
4832     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4833     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4834     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4835     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4836
4837     state = 0xdeadbee;
4838     action = 0xdeadbee;
4839     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4840     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4841     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4842     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4843
4844     state = 0xdeadbee;
4845     action = 0xdeadbee;
4846     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4847     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4848     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4849     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4850
4851     state = 0xdeadbee;
4852     action = 0xdeadbee;
4853     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4854     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4855     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4856     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4857
4858     state = 0xdeadbee;
4859     action = 0xdeadbee;
4860     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4861     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4862     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4863     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4864
4865     state = 0xdeadbee;
4866     action = 0xdeadbee;
4867     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4868     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4869     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4870     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4871
4872     state = 0xdeadbee;
4873     action = 0xdeadbee;
4874     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4875     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4876     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4877     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4878
4879     state = 0xdeadbee;
4880     action = 0xdeadbee;
4881     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4882     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4883     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4884     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4885
4886     state = 0xdeadbee;
4887     action = 0xdeadbee;
4888     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4889     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4890     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4891     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4892
4893     state = 0xdeadbee;
4894     action = 0xdeadbee;
4895     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4896     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4897     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4898     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4899
4900     state = 0xdeadbee;
4901     action = 0xdeadbee;
4902     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4903     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4904     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4905     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4906
4907     state = 0xdeadbee;
4908     action = 0xdeadbee;
4909     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4910     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4911     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4912     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4913
4914     state = 0xdeadbee;
4915     action = 0xdeadbee;
4916     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4917     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4918     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4919     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4920
4921     state = 0xdeadbee;
4922     action = 0xdeadbee;
4923     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4924     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4925     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4926     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4927
4928     state = 0xdeadbee;
4929     action = 0xdeadbee;
4930     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4931     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4932     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4933     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4934
4935     state = 0xdeadbee;
4936     action = 0xdeadbee;
4937     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4938     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4939     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4940     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4941
4942     state = 0xdeadbee;
4943     action = 0xdeadbee;
4944     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4945     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4946     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4947     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4948
4949     state = 0xdeadbee;
4950     action = 0xdeadbee;
4951     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4952     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4953     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4954     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4955
4956     state = 0xdeadbee;
4957     action = 0xdeadbee;
4958     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4959     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4960     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4961     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4962
4963     state = 0xdeadbee;
4964     action = 0xdeadbee;
4965     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4966     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4967     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4968     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4969
4970     state = 0xdeadbee;
4971     action = 0xdeadbee;
4972     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4973     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4974     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4975     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4976
4977     state = 0xdeadbee;
4978     action = 0xdeadbee;
4979     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4980     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4981     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4982     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4983
4984     state = 0xdeadbee;
4985     action = 0xdeadbee;
4986     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4987     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4988     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4989     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4990
4991     state = 0xdeadbee;
4992     action = 0xdeadbee;
4993     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4994     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4995     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4996     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4997
4998     state = 0xdeadbee;
4999     action = 0xdeadbee;
5000     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5001     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5002     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5003     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5004
5005     state = 0xdeadbee;
5006     action = 0xdeadbee;
5007     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5008     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5009     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5010     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5011
5012     state = 0xdeadbee;
5013     action = 0xdeadbee;
5014     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5015     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5016     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5017     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5018
5019     state = 0xdeadbee;
5020     action = 0xdeadbee;
5021     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5022     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5023     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5024     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5025
5026     state = 0xdeadbee;
5027     action = 0xdeadbee;
5028     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5029     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5030     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5031     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5032
5033     state = 0xdeadbee;
5034     action = 0xdeadbee;
5035     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5036     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5037     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5038     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5039
5040     r = MsiDoAction( hpkg, "CostInitialize");
5041     ok( r == ERROR_SUCCESS, "cost init failed\n");
5042
5043     state = 0xdeadbee;
5044     action = 0xdeadbee;
5045     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5046     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5047     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5048     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5049
5050     state = 0xdeadbee;
5051     action = 0xdeadbee;
5052     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5053     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5054     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5055     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5056
5057     state = 0xdeadbee;
5058     action = 0xdeadbee;
5059     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5060     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5061     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5062     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5063
5064     state = 0xdeadbee;
5065     action = 0xdeadbee;
5066     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5067     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5068     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5069     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5070
5071     state = 0xdeadbee;
5072     action = 0xdeadbee;
5073     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5074     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5075     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5076     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5077
5078     state = 0xdeadbee;
5079     action = 0xdeadbee;
5080     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5081     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5082     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5083     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5084
5085     state = 0xdeadbee;
5086     action = 0xdeadbee;
5087     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5088     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5089     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5090     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5091
5092     state = 0xdeadbee;
5093     action = 0xdeadbee;
5094     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5095     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5096     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5097     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5098
5099     state = 0xdeadbee;
5100     action = 0xdeadbee;
5101     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5102     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5103     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5104     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5105
5106     state = 0xdeadbee;
5107     action = 0xdeadbee;
5108     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5109     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5110     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5111     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5112
5113     state = 0xdeadbee;
5114     action = 0xdeadbee;
5115     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5116     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5117     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5118     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5119
5120     state = 0xdeadbee;
5121     action = 0xdeadbee;
5122     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5123     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5124     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5125     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5126
5127     state = 0xdeadbee;
5128     action = 0xdeadbee;
5129     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5130     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5131     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5132     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5133
5134     state = 0xdeadbee;
5135     action = 0xdeadbee;
5136     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5137     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5138     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5139     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5140
5141     state = 0xdeadbee;
5142     action = 0xdeadbee;
5143     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5144     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5145     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5146     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5147
5148     state = 0xdeadbee;
5149     action = 0xdeadbee;
5150     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5152     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5153     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5154
5155     state = 0xdeadbee;
5156     action = 0xdeadbee;
5157     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5159     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5160     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5161
5162     state = 0xdeadbee;
5163     action = 0xdeadbee;
5164     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5166     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5167     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5168
5169     state = 0xdeadbee;
5170     action = 0xdeadbee;
5171     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5172     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5173     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5174     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5175
5176     state = 0xdeadbee;
5177     action = 0xdeadbee;
5178     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5179     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5180     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5181     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5182
5183     state = 0xdeadbee;
5184     action = 0xdeadbee;
5185     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5186     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5187     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5188     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5189
5190     state = 0xdeadbee;
5191     action = 0xdeadbee;
5192     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5193     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5194     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5195     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5196
5197     state = 0xdeadbee;
5198     action = 0xdeadbee;
5199     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5201     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5202     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5203
5204     state = 0xdeadbee;
5205     action = 0xdeadbee;
5206     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5208     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5209     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5210
5211     state = 0xdeadbee;
5212     action = 0xdeadbee;
5213     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5215     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5216     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5217
5218     state = 0xdeadbee;
5219     action = 0xdeadbee;
5220     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5222     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5223     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5224
5225     state = 0xdeadbee;
5226     action = 0xdeadbee;
5227     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5228     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5229     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5230     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5231
5232     state = 0xdeadbee;
5233     action = 0xdeadbee;
5234     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5235     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5236     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5237     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5238
5239     state = 0xdeadbee;
5240     action = 0xdeadbee;
5241     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5243     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5244     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5245
5246     state = 0xdeadbee;
5247     action = 0xdeadbee;
5248     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5249     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5250     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5251     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5252
5253     state = 0xdeadbee;
5254     action = 0xdeadbee;
5255     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5256     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5257     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5258     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5259
5260     state = 0xdeadbee;
5261     action = 0xdeadbee;
5262     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5263     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5264     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5265     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5266
5267     state = 0xdeadbee;
5268     action = 0xdeadbee;
5269     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5270     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5271     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5272     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5273
5274     r = MsiDoAction( hpkg, "FileCost");
5275     ok( r == ERROR_SUCCESS, "file cost failed\n");
5276
5277     state = 0xdeadbee;
5278     action = 0xdeadbee;
5279     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
5306     action = 0xdeadbee;
5307     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5308     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5309     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5310     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5311
5312     state = 0xdeadbee;
5313     action = 0xdeadbee;
5314     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5315     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5316     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5317     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5318
5319     state = 0xdeadbee;
5320     action = 0xdeadbee;
5321     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5322     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5323     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5324     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5325
5326     state = 0xdeadbee;
5327     action = 0xdeadbee;
5328     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5329     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5330     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5331     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5332
5333     state = 0xdeadbee;
5334     action = 0xdeadbee;
5335     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5336     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5337     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5338     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5339
5340     state = 0xdeadbee;
5341     action = 0xdeadbee;
5342     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5343     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5344     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5345     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5346
5347     state = 0xdeadbee;
5348     action = 0xdeadbee;
5349     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5350     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5351     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5352     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5353
5354     state = 0xdeadbee;
5355     action = 0xdeadbee;
5356     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5357     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5358     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5359     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5360
5361     state = 0xdeadbee;
5362     action = 0xdeadbee;
5363     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5364     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5365     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5366     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5367
5368     state = 0xdeadbee;
5369     action = 0xdeadbee;
5370     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5371     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5372     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5373     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5374
5375     state = 0xdeadbee;
5376     action = 0xdeadbee;
5377     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5378     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5379     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5380     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5381
5382     state = 0xdeadbee;
5383     action = 0xdeadbee;
5384     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5385     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5386     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5387     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5388
5389     state = 0xdeadbee;
5390     action = 0xdeadbee;
5391     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5392     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5393     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5394     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5395
5396     state = 0xdeadbee;
5397     action = 0xdeadbee;
5398     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5399     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5400     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5401     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5402
5403     state = 0xdeadbee;
5404     action = 0xdeadbee;
5405     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5406     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5407     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5408     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5409
5410     state = 0xdeadbee;
5411     action = 0xdeadbee;
5412     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5413     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5414     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5415     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5416
5417     state = 0xdeadbee;
5418     action = 0xdeadbee;
5419     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5420     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5421     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5422     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5423
5424     state = 0xdeadbee;
5425     action = 0xdeadbee;
5426     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5427     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5428     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5429     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5430
5431     state = 0xdeadbee;
5432     action = 0xdeadbee;
5433     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5434     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5435     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5436     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5437
5438     state = 0xdeadbee;
5439     action = 0xdeadbee;
5440     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5441     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5442     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5443     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5444
5445     state = 0xdeadbee;
5446     action = 0xdeadbee;
5447     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5448     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5449     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5450     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5451
5452     state = 0xdeadbee;
5453     action = 0xdeadbee;
5454     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5455     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5456     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5457     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5458
5459     state = 0xdeadbee;
5460     action = 0xdeadbee;
5461     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5462     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5463     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5464     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5465
5466     state = 0xdeadbee;
5467     action = 0xdeadbee;
5468     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5469     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5470     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5471     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5472
5473     state = 0xdeadbee;
5474     action = 0xdeadbee;
5475     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5476     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5477     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5478     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5479
5480     state = 0xdeadbee;
5481     action = 0xdeadbee;
5482     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5483     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5484     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5485     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5486
5487     state = 0xdeadbee;
5488     action = 0xdeadbee;
5489     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5490     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5491     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5492     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5493
5494     state = 0xdeadbee;
5495     action = 0xdeadbee;
5496     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5497     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5498     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5499     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5500
5501     state = 0xdeadbee;
5502     action = 0xdeadbee;
5503     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5504     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5505     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5506     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5507
5508     r = MsiDoAction( hpkg, "CostFinalize");
5509     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5510
5511     state = 0xdeadbee;
5512     action = 0xdeadbee;
5513     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5514     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5515     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5516     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5517
5518     state = 0xdeadbee;
5519     action = 0xdeadbee;
5520     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5521     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5522     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5523     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5524
5525     state = 0xdeadbee;
5526     action = 0xdeadbee;
5527     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5528     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5529     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5530     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5531
5532     state = 0xdeadbee;
5533     action = 0xdeadbee;
5534     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5535     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5536     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5537     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5538
5539     state = 0xdeadbee;
5540     action = 0xdeadbee;
5541     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5542     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5543     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5544     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5545
5546     state = 0xdeadbee;
5547     action = 0xdeadbee;
5548     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5549     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5550     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5551     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5552
5553     state = 0xdeadbee;
5554     action = 0xdeadbee;
5555     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5556     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5557     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5558     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5559
5560     state = 0xdeadbee;
5561     action = 0xdeadbee;
5562     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5563     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5564     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5565     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5566
5567     state = 0xdeadbee;
5568     action = 0xdeadbee;
5569     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5570     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5571     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5572     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5573
5574     state = 0xdeadbee;
5575     action = 0xdeadbee;
5576     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5577     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5578     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5579     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5580
5581     state = 0xdeadbee;
5582     action = 0xdeadbee;
5583     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5584     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5585     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5586     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5587
5588     state = 0xdeadbee;
5589     action = 0xdeadbee;
5590     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5591     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5592     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5593     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5594
5595     state = 0xdeadbee;
5596     action = 0xdeadbee;
5597     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5598     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5599     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5600     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5601
5602     state = 0xdeadbee;
5603     action = 0xdeadbee;
5604     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5605     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5606     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5607     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5608
5609     state = 0xdeadbee;
5610     action = 0xdeadbee;
5611     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5612     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5613     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5614     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5615
5616     state = 0xdeadbee;
5617     action = 0xdeadbee;
5618     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5619     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5620     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5621     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5622
5623     state = 0xdeadbee;
5624     action = 0xdeadbee;
5625     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5626     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5627     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5628     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5629
5630     state = 0xdeadbee;
5631     action = 0xdeadbee;
5632     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5633     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5634     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5635     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5636
5637     state = 0xdeadbee;
5638     action = 0xdeadbee;
5639     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5640     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5641     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5642     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5643
5644     state = 0xdeadbee;
5645     action = 0xdeadbee;
5646     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5647     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5648     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5649     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5650
5651     state = 0xdeadbee;
5652     action = 0xdeadbee;
5653     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5654     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5655     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5656     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5657
5658     state = 0xdeadbee;
5659     action = 0xdeadbee;
5660     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5661     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5662     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5663     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5664
5665     state = 0xdeadbee;
5666     action = 0xdeadbee;
5667     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5668     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5669     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5670     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5671
5672     state = 0xdeadbee;
5673     action = 0xdeadbee;
5674     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5675     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5676     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5677     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5678
5679     state = 0xdeadbee;
5680     action = 0xdeadbee;
5681     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5682     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5683     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5684     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5685
5686     state = 0xdeadbee;
5687     action = 0xdeadbee;
5688     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5689     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5690     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5691     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5692
5693     state = 0xdeadbee;
5694     action = 0xdeadbee;
5695     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5696     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5697     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5698     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5699
5700     state = 0xdeadbee;
5701     action = 0xdeadbee;
5702     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5703     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5704     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5705     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5706
5707     state = 0xdeadbee;
5708     action = 0xdeadbee;
5709     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5710     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5711     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5712     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5713
5714     state = 0xdeadbee;
5715     action = 0xdeadbee;
5716     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5717     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5718     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5719     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5720
5721     state = 0xdeadbee;
5722     action = 0xdeadbee;
5723     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5724     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5725     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5726     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5727
5728     state = 0xdeadbee;
5729     action = 0xdeadbee;
5730     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5731     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5732     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5733     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5734
5735     state = 0xdeadbee;
5736     action = 0xdeadbee;
5737     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5738     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5739     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5740     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5741
5742     MsiCloseHandle(hpkg);
5743
5744     /* uninstall the product */
5745     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5746     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5747
5748     /* all features installed from source */
5749     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5750     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5751
5752     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5753     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5754
5755     /* this property must not be in the saved msi file */
5756     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5757     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5758
5759     r = package_from_db( hdb, &hpkg );
5760     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5761
5762     state = 0xdeadbee;
5763     action = 0xdeadbee;
5764     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5765     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5766     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5767     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5768
5769     state = 0xdeadbee;
5770     action = 0xdeadbee;
5771     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5772     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5773     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5774     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5775
5776     state = 0xdeadbee;
5777     action = 0xdeadbee;
5778     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5779     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5780     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5781     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5782
5783     state = 0xdeadbee;
5784     action = 0xdeadbee;
5785     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5786     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5787     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5788     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5789
5790     state = 0xdeadbee;
5791     action = 0xdeadbee;
5792     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5793     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5794     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5795     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5796
5797     state = 0xdeadbee;
5798     action = 0xdeadbee;
5799     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5800     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5801     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5802     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5803
5804     state = 0xdeadbee;
5805     action = 0xdeadbee;
5806     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5807     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5808     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5809     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5810
5811     state = 0xdeadbee;
5812     action = 0xdeadbee;
5813     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5814     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5815     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5816     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5817
5818     state = 0xdeadbee;
5819     action = 0xdeadbee;
5820     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5821     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5822     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5823     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5824
5825     state = 0xdeadbee;
5826     action = 0xdeadbee;
5827     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5828     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5829     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5830     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5831
5832     state = 0xdeadbee;
5833     action = 0xdeadbee;
5834     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5835     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5836     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5837     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5838
5839     state = 0xdeadbee;
5840     action = 0xdeadbee;
5841     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5842     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5843     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5844     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5845
5846     state = 0xdeadbee;
5847     action = 0xdeadbee;
5848     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5849     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5850     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5851     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5852
5853     state = 0xdeadbee;
5854     action = 0xdeadbee;
5855     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5856     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5857     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5858     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5859
5860     state = 0xdeadbee;
5861     action = 0xdeadbee;
5862     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5863     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5864     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5865     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5866
5867     state = 0xdeadbee;
5868     action = 0xdeadbee;
5869     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5870     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5871     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5872     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5873
5874     state = 0xdeadbee;
5875     action = 0xdeadbee;
5876     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5877     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5878     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5879     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5880
5881     state = 0xdeadbee;
5882     action = 0xdeadbee;
5883     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5884     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5885     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5886     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5887
5888     state = 0xdeadbee;
5889     action = 0xdeadbee;
5890     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5891     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5892     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5893     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5894
5895     state = 0xdeadbee;
5896     action = 0xdeadbee;
5897     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5898     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5899     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5900     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5901
5902     state = 0xdeadbee;
5903     action = 0xdeadbee;
5904     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5905     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5906     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5907     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5908
5909     state = 0xdeadbee;
5910     action = 0xdeadbee;
5911     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5912     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5913     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5914     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5915
5916     state = 0xdeadbee;
5917     action = 0xdeadbee;
5918     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5919     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5920     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5921     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5922
5923     state = 0xdeadbee;
5924     action = 0xdeadbee;
5925     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5926     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5927     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5928     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5929
5930     state = 0xdeadbee;
5931     action = 0xdeadbee;
5932     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5933     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5934     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5935     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5936
5937     state = 0xdeadbee;
5938     action = 0xdeadbee;
5939     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5940     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5941     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5942     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5943
5944     state = 0xdeadbee;
5945     action = 0xdeadbee;
5946     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5947     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5948     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5949     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5950
5951     state = 0xdeadbee;
5952     action = 0xdeadbee;
5953     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5954     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5955     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5956     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5957
5958     state = 0xdeadbee;
5959     action = 0xdeadbee;
5960     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5961     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5962     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5963     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5964
5965     state = 0xdeadbee;
5966     action = 0xdeadbee;
5967     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5968     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5969     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5970     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5971
5972     state = 0xdeadbee;
5973     action = 0xdeadbee;
5974     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5975     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5976     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5977     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5978
5979     state = 0xdeadbee;
5980     action = 0xdeadbee;
5981     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5982     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5983     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5984     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5985
5986     state = 0xdeadbee;
5987     action = 0xdeadbee;
5988     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5989     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5990     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5991     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5992
5993     r = MsiDoAction( hpkg, "CostInitialize");
5994     ok( r == ERROR_SUCCESS, "cost init failed\n");
5995
5996     state = 0xdeadbee;
5997     action = 0xdeadbee;
5998     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5999     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6000     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6001     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6002
6003     state = 0xdeadbee;
6004     action = 0xdeadbee;
6005     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6006     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6007     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6008     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6009
6010     state = 0xdeadbee;
6011     action = 0xdeadbee;
6012     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6013     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6014     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6015     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6016
6017     state = 0xdeadbee;
6018     action = 0xdeadbee;
6019     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6020     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6021     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6022     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6023
6024     state = 0xdeadbee;
6025     action = 0xdeadbee;
6026     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6027     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6028     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6029     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6030
6031     state = 0xdeadbee;
6032     action = 0xdeadbee;
6033     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6034     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6035     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6036     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6037
6038     state = 0xdeadbee;
6039     action = 0xdeadbee;
6040     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6041     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6042     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6043     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6044
6045     state = 0xdeadbee;
6046     action = 0xdeadbee;
6047     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6048     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6049     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6050     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6051
6052     state = 0xdeadbee;
6053     action = 0xdeadbee;
6054     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6055     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6056     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6057     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6058
6059     state = 0xdeadbee;
6060     action = 0xdeadbee;
6061     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6062     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6063     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6064     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6065
6066     state = 0xdeadbee;
6067     action = 0xdeadbee;
6068     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6069     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6070     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6071     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6072
6073     state = 0xdeadbee;
6074     action = 0xdeadbee;
6075     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6076     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6077     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6078     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6079
6080     state = 0xdeadbee;
6081     action = 0xdeadbee;
6082     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6083     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6084     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6085     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6086
6087     state = 0xdeadbee;
6088     action = 0xdeadbee;
6089     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6090     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6091     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6092     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6093
6094     state = 0xdeadbee;
6095     action = 0xdeadbee;
6096     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6097     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6098     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6099     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6100
6101     state = 0xdeadbee;
6102     action = 0xdeadbee;
6103     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6104     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6105     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6106     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6107
6108     state = 0xdeadbee;
6109     action = 0xdeadbee;
6110     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6111     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6112     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6113     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6114
6115     state = 0xdeadbee;
6116     action = 0xdeadbee;
6117     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6118     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6119     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6120     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6121
6122     state = 0xdeadbee;
6123     action = 0xdeadbee;
6124     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6125     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6126     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6127     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6128
6129     state = 0xdeadbee;
6130     action = 0xdeadbee;
6131     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6132     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6133     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6134     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6135
6136     state = 0xdeadbee;
6137     action = 0xdeadbee;
6138     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6139     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6140     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6141     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6142
6143     state = 0xdeadbee;
6144     action = 0xdeadbee;
6145     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6146     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6147     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6148     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6149
6150     state = 0xdeadbee;
6151     action = 0xdeadbee;
6152     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6153     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6154     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6155     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6156
6157     state = 0xdeadbee;
6158     action = 0xdeadbee;
6159     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6160     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6161     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6162     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6163
6164     state = 0xdeadbee;
6165     action = 0xdeadbee;
6166     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6167     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6168     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6169     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6170
6171     state = 0xdeadbee;
6172     action = 0xdeadbee;
6173     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6174     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6175     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6176     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6177
6178     state = 0xdeadbee;
6179     action = 0xdeadbee;
6180     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6181     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6182     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6183     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6184
6185     state = 0xdeadbee;
6186     action = 0xdeadbee;
6187     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6188     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6189     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6190     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6191
6192     state = 0xdeadbee;
6193     action = 0xdeadbee;
6194     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6195     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6196     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6197     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6198
6199     state = 0xdeadbee;
6200     action = 0xdeadbee;
6201     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6202     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6203     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6204     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6205
6206     state = 0xdeadbee;
6207     action = 0xdeadbee;
6208     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6209     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6210     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6211     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6212
6213     state = 0xdeadbee;
6214     action = 0xdeadbee;
6215     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6216     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6217     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6218     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6219
6220     state = 0xdeadbee;
6221     action = 0xdeadbee;
6222     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6223     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6224     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6225     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6226
6227     r = MsiDoAction( hpkg, "FileCost");
6228     ok( r == ERROR_SUCCESS, "file cost failed\n");
6229
6230     state = 0xdeadbee;
6231     action = 0xdeadbee;
6232     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
6259     action = 0xdeadbee;
6260     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6261     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6262     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6263     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6264
6265     state = 0xdeadbee;
6266     action = 0xdeadbee;
6267     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6268     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6269     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6270     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6271
6272     state = 0xdeadbee;
6273     action = 0xdeadbee;
6274     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6275     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6276     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6277     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6278
6279     state = 0xdeadbee;
6280     action = 0xdeadbee;
6281     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6282     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6283     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6284     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6285
6286     state = 0xdeadbee;
6287     action = 0xdeadbee;
6288     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6289     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6290     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6291     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6292
6293     state = 0xdeadbee;
6294     action = 0xdeadbee;
6295     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6296     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6297     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6298     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6299
6300     state = 0xdeadbee;
6301     action = 0xdeadbee;
6302     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6303     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6304     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6305     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6306
6307     state = 0xdeadbee;
6308     action = 0xdeadbee;
6309     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6310     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6311     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6312     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6313
6314     state = 0xdeadbee;
6315     action = 0xdeadbee;
6316     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6317     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6318     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6319     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6320
6321     state = 0xdeadbee;
6322     action = 0xdeadbee;
6323     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6324     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6325     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6326     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6327
6328     state = 0xdeadbee;
6329     action = 0xdeadbee;
6330     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6331     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6332     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6333     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6334
6335     state = 0xdeadbee;
6336     action = 0xdeadbee;
6337     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6338     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6339     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6340     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6341
6342     state = 0xdeadbee;
6343     action = 0xdeadbee;
6344     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6345     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6346     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6347     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6348
6349     state = 0xdeadbee;
6350     action = 0xdeadbee;
6351     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6352     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6353     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6354     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6355
6356     state = 0xdeadbee;
6357     action = 0xdeadbee;
6358     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6359     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6360     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6361     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6362
6363     state = 0xdeadbee;
6364     action = 0xdeadbee;
6365     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6366     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6367     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6368     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6369
6370     state = 0xdeadbee;
6371     action = 0xdeadbee;
6372     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6373     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6374     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6375     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6376
6377     state = 0xdeadbee;
6378     action = 0xdeadbee;
6379     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6380     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6381     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6382     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6383
6384     state = 0xdeadbee;
6385     action = 0xdeadbee;
6386     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6387     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6388     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6389     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6390
6391     state = 0xdeadbee;
6392     action = 0xdeadbee;
6393     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6394     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6395     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6396     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6397
6398     state = 0xdeadbee;
6399     action = 0xdeadbee;
6400     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6401     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6402     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6403     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6404
6405     state = 0xdeadbee;
6406     action = 0xdeadbee;
6407     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6408     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6409     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6410     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6411
6412     state = 0xdeadbee;
6413     action = 0xdeadbee;
6414     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6415     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6416     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6417     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6418
6419     state = 0xdeadbee;
6420     action = 0xdeadbee;
6421     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6422     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6423     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6424     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6425
6426     state = 0xdeadbee;
6427     action = 0xdeadbee;
6428     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6429     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6430     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6431     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6432
6433     state = 0xdeadbee;
6434     action = 0xdeadbee;
6435     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6436     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6437     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6438     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6439
6440     state = 0xdeadbee;
6441     action = 0xdeadbee;
6442     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6443     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6444     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6445     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6446
6447     state = 0xdeadbee;
6448     action = 0xdeadbee;
6449     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6450     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6451     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6452     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6453
6454     state = 0xdeadbee;
6455     action = 0xdeadbee;
6456     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6457     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6458     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6459     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6460
6461     r = MsiDoAction( hpkg, "CostFinalize");
6462     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6463
6464     state = 0xdeadbee;
6465     action = 0xdeadbee;
6466     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6468     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6469     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6470
6471     state = 0xdeadbee;
6472     action = 0xdeadbee;
6473     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6475     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6476     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6477
6478     state = 0xdeadbee;
6479     action = 0xdeadbee;
6480     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6482     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6483     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6484
6485     state = 0xdeadbee;
6486     action = 0xdeadbee;
6487     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6489     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6490     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6491
6492     state = 0xdeadbee;
6493     action = 0xdeadbee;
6494     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6495     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6496     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6497     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6498
6499     state = 0xdeadbee;
6500     action = 0xdeadbee;
6501     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6502     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6503     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6504     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6505
6506     state = 0xdeadbee;
6507     action = 0xdeadbee;
6508     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6509     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6510     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6511     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6512
6513     state = 0xdeadbee;
6514     action = 0xdeadbee;
6515     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6516     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6517     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6518     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6519
6520     state = 0xdeadbee;
6521     action = 0xdeadbee;
6522     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6523     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6524     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6525     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6526
6527     state = 0xdeadbee;
6528     action = 0xdeadbee;
6529     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6530     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6531     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6532     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6533
6534     state = 0xdeadbee;
6535     action = 0xdeadbee;
6536     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6537     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6538     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6539     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6540
6541     state = 0xdeadbee;
6542     action = 0xdeadbee;
6543     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6544     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6545     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6546     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6547
6548     state = 0xdeadbee;
6549     action = 0xdeadbee;
6550     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6551     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6552     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6553     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6554
6555     state = 0xdeadbee;
6556     action = 0xdeadbee;
6557     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6558     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6559     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6560     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6561
6562     state = 0xdeadbee;
6563     action = 0xdeadbee;
6564     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6565     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6566     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6567     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6568
6569     state = 0xdeadbee;
6570     action = 0xdeadbee;
6571     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6572     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6573     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6574     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6575
6576     state = 0xdeadbee;
6577     action = 0xdeadbee;
6578     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6579     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6580     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6581     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6582
6583     state = 0xdeadbee;
6584     action = 0xdeadbee;
6585     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6586     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6587     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6588     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6589
6590     state = 0xdeadbee;
6591     action = 0xdeadbee;
6592     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6593     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6594     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6595     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6596
6597     state = 0xdeadbee;
6598     action = 0xdeadbee;
6599     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6600     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6601     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6602     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6603
6604     state = 0xdeadbee;
6605     action = 0xdeadbee;
6606     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6607     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6608     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6609     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6610
6611     state = 0xdeadbee;
6612     action = 0xdeadbee;
6613     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6614     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6615     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6616     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6617
6618     state = 0xdeadbee;
6619     action = 0xdeadbee;
6620     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6621     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6622     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6623     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6624
6625     state = 0xdeadbee;
6626     action = 0xdeadbee;
6627     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6628     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6629     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6630     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6631
6632     state = 0xdeadbee;
6633     action = 0xdeadbee;
6634     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6635     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6636     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6637     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6638
6639     state = 0xdeadbee;
6640     action = 0xdeadbee;
6641     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6642     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6643     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6644     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6645
6646     state = 0xdeadbee;
6647     action = 0xdeadbee;
6648     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6649     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6650     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6651     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6652
6653     state = 0xdeadbee;
6654     action = 0xdeadbee;
6655     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6656     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6657     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6658     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6659
6660     state = 0xdeadbee;
6661     action = 0xdeadbee;
6662     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6663     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6664     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6665     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6666
6667     state = 0xdeadbee;
6668     action = 0xdeadbee;
6669     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6670     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6671     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6672     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6673
6674     state = 0xdeadbee;
6675     action = 0xdeadbee;
6676     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6677     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6678     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6679     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6680
6681     state = 0xdeadbee;
6682     action = 0xdeadbee;
6683     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6684     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6685     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6686     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6687
6688     state = 0xdeadbee;
6689     action = 0xdeadbee;
6690     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6691     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6692     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6693     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6694
6695     MsiCloseHandle(hpkg);
6696
6697     /* reinstall the product */
6698     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6700
6701     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6702     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6703
6704     /* this property must not be in the saved msi file */
6705     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6706     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6707
6708     r = package_from_db( hdb, &hpkg );
6709     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6710
6711     state = 0xdeadbee;
6712     action = 0xdeadbee;
6713     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6714     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6715     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6716     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6717
6718     state = 0xdeadbee;
6719     action = 0xdeadbee;
6720     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6721     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6722     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6723     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6724
6725     state = 0xdeadbee;
6726     action = 0xdeadbee;
6727     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6728     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6729     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6730     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6731
6732     state = 0xdeadbee;
6733     action = 0xdeadbee;
6734     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6735     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6736     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6737     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6738
6739     state = 0xdeadbee;
6740     action = 0xdeadbee;
6741     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6742     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6743     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6744     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6745
6746     state = 0xdeadbee;
6747     action = 0xdeadbee;
6748     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6749     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6750     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6751     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6752
6753     state = 0xdeadbee;
6754     action = 0xdeadbee;
6755     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6756     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6757     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6758     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6759
6760     state = 0xdeadbee;
6761     action = 0xdeadbee;
6762     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6763     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6764     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6765     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6766
6767     state = 0xdeadbee;
6768     action = 0xdeadbee;
6769     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6770     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6771     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6772     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6773
6774     state = 0xdeadbee;
6775     action = 0xdeadbee;
6776     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6777     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6778     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6779     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6780
6781     state = 0xdeadbee;
6782     action = 0xdeadbee;
6783     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6784     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6785     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6786     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6787
6788     state = 0xdeadbee;
6789     action = 0xdeadbee;
6790     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6791     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6792     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6793     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6794
6795     state = 0xdeadbee;
6796     action = 0xdeadbee;
6797     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6798     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6799     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6800     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6801
6802     state = 0xdeadbee;
6803     action = 0xdeadbee;
6804     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6805     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6806     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6807     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6808
6809     state = 0xdeadbee;
6810     action = 0xdeadbee;
6811     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6812     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6813     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6814     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6815
6816     state = 0xdeadbee;
6817     action = 0xdeadbee;
6818     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6819     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6820     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6821     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6822
6823     state = 0xdeadbee;
6824     action = 0xdeadbee;
6825     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6826     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6827     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6828     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6829
6830     state = 0xdeadbee;
6831     action = 0xdeadbee;
6832     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6833     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6834     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6835     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6836
6837     state = 0xdeadbee;
6838     action = 0xdeadbee;
6839     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6840     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6841     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6842     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6843
6844     state = 0xdeadbee;
6845     action = 0xdeadbee;
6846     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6847     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6848     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6849     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6850
6851     state = 0xdeadbee;
6852     action = 0xdeadbee;
6853     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6854     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6855     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6856     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6857
6858     state = 0xdeadbee;
6859     action = 0xdeadbee;
6860     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6861     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6862     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6863     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6864
6865     state = 0xdeadbee;
6866     action = 0xdeadbee;
6867     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6868     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6869     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6870     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6871
6872     state = 0xdeadbee;
6873     action = 0xdeadbee;
6874     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6875     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6876     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6877     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6878
6879     state = 0xdeadbee;
6880     action = 0xdeadbee;
6881     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6882     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6883     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6884     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6885
6886     state = 0xdeadbee;
6887     action = 0xdeadbee;
6888     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6889     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6890     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6891     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6892
6893     state = 0xdeadbee;
6894     action = 0xdeadbee;
6895     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6896     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6897     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6898     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6899
6900     state = 0xdeadbee;
6901     action = 0xdeadbee;
6902     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6903     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6904     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6905     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6906
6907     state = 0xdeadbee;
6908     action = 0xdeadbee;
6909     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6910     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6911     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6912     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6913
6914     state = 0xdeadbee;
6915     action = 0xdeadbee;
6916     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6917     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6918     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6919     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6920
6921     state = 0xdeadbee;
6922     action = 0xdeadbee;
6923     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6924     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6925     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6926     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6927
6928     state = 0xdeadbee;
6929     action = 0xdeadbee;
6930     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6931     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6932     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6933     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6934
6935     state = 0xdeadbee;
6936     action = 0xdeadbee;
6937     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6938     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6939     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6940     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6941
6942     r = MsiDoAction( hpkg, "CostInitialize");
6943     ok( r == ERROR_SUCCESS, "cost init failed\n");
6944
6945     state = 0xdeadbee;
6946     action = 0xdeadbee;
6947     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6948     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6949     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6950     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6951
6952     state = 0xdeadbee;
6953     action = 0xdeadbee;
6954     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6955     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6956     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6957     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6958
6959     state = 0xdeadbee;
6960     action = 0xdeadbee;
6961     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6962     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6963     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6964     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6965
6966     state = 0xdeadbee;
6967     action = 0xdeadbee;
6968     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6969     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6970     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6971     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6972
6973     state = 0xdeadbee;
6974     action = 0xdeadbee;
6975     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6976     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6977     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6978     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6979
6980     state = 0xdeadbee;
6981     action = 0xdeadbee;
6982     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6983     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6984     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6985     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6986
6987     state = 0xdeadbee;
6988     action = 0xdeadbee;
6989     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6990     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6991     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6992     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6993
6994     state = 0xdeadbee;
6995     action = 0xdeadbee;
6996     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6997     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6998     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6999     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7000
7001     state = 0xdeadbee;
7002     action = 0xdeadbee;
7003     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7004     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7005     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7006     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7007
7008     state = 0xdeadbee;
7009     action = 0xdeadbee;
7010     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7011     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7012     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7013     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7014
7015     state = 0xdeadbee;
7016     action = 0xdeadbee;
7017     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7018     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7019     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7020     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7021
7022     state = 0xdeadbee;
7023     action = 0xdeadbee;
7024     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7025     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7026     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7027     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7028
7029     state = 0xdeadbee;
7030     action = 0xdeadbee;
7031     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7032     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7033     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7034     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7035
7036     state = 0xdeadbee;
7037     action = 0xdeadbee;
7038     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7039     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7040     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7041     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7042
7043     state = 0xdeadbee;
7044     action = 0xdeadbee;
7045     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7046     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7047     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7048     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7049
7050     state = 0xdeadbee;
7051     action = 0xdeadbee;
7052     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7053     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7054     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7055     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7056
7057     state = 0xdeadbee;
7058     action = 0xdeadbee;
7059     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7060     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7061     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7062     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7063
7064     state = 0xdeadbee;
7065     action = 0xdeadbee;
7066     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7067     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7068     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7069     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7070
7071     state = 0xdeadbee;
7072     action = 0xdeadbee;
7073     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7074     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7075     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7076     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7077
7078     state = 0xdeadbee;
7079     action = 0xdeadbee;
7080     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7081     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7082     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7083     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7084
7085     state = 0xdeadbee;
7086     action = 0xdeadbee;
7087     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7088     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7089     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7090     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7091
7092     state = 0xdeadbee;
7093     action = 0xdeadbee;
7094     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7095     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7096     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7097     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7098
7099     state = 0xdeadbee;
7100     action = 0xdeadbee;
7101     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7102     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7103     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7104     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7105
7106     state = 0xdeadbee;
7107     action = 0xdeadbee;
7108     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7109     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7110     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7111     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7112
7113     state = 0xdeadbee;
7114     action = 0xdeadbee;
7115     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7116     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7117     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7118     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7119
7120     state = 0xdeadbee;
7121     action = 0xdeadbee;
7122     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7123     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7124     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7125     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7126
7127     state = 0xdeadbee;
7128     action = 0xdeadbee;
7129     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7130     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7131     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7132     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7133
7134     state = 0xdeadbee;
7135     action = 0xdeadbee;
7136     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7137     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7138     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7139     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7140
7141     state = 0xdeadbee;
7142     action = 0xdeadbee;
7143     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7144     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7145     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7146     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7147
7148     state = 0xdeadbee;
7149     action = 0xdeadbee;
7150     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7152     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7153     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7154
7155     state = 0xdeadbee;
7156     action = 0xdeadbee;
7157     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7159     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7160     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7161
7162     state = 0xdeadbee;
7163     action = 0xdeadbee;
7164     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7166     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7167     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7168
7169     state = 0xdeadbee;
7170     action = 0xdeadbee;
7171     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7172     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7173     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7174     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7175
7176     r = MsiDoAction( hpkg, "FileCost");
7177     ok( r == ERROR_SUCCESS, "file cost failed\n");
7178
7179     state = 0xdeadbee;
7180     action = 0xdeadbee;
7181     r = MsiGetFeatureState(hpkg, "one", &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 = MsiGetFeatureState(hpkg, "two", &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 = MsiGetFeatureState(hpkg, "three", &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 = MsiGetFeatureState(hpkg, "four", &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     state = 0xdeadbee;
7208     action = 0xdeadbee;
7209     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7210     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7211     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7212     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7213
7214     state = 0xdeadbee;
7215     action = 0xdeadbee;
7216     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7217     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7218     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7219     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7220
7221     state = 0xdeadbee;
7222     action = 0xdeadbee;
7223     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7224     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7225     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7226     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7227
7228     state = 0xdeadbee;
7229     action = 0xdeadbee;
7230     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7232     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7233     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7234
7235     state = 0xdeadbee;
7236     action = 0xdeadbee;
7237     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7239     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7240     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7241
7242     state = 0xdeadbee;
7243     action = 0xdeadbee;
7244     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7246     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7247     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7248
7249     state = 0xdeadbee;
7250     action = 0xdeadbee;
7251     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7252     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7253     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7254     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7255
7256     state = 0xdeadbee;
7257     action = 0xdeadbee;
7258     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7259     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7260     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7261     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7262
7263     state = 0xdeadbee;
7264     action = 0xdeadbee;
7265     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7266     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7267     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7268     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7269
7270     state = 0xdeadbee;
7271     action = 0xdeadbee;
7272     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7273     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7274     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7275     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7276
7277     state = 0xdeadbee;
7278     action = 0xdeadbee;
7279     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7280     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7281     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7282     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7283
7284     state = 0xdeadbee;
7285     action = 0xdeadbee;
7286     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7287     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7288     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7289     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7290
7291     state = 0xdeadbee;
7292     action = 0xdeadbee;
7293     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7294     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7295     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7296     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7297
7298     state = 0xdeadbee;
7299     action = 0xdeadbee;
7300     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7301     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7302     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7303     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7304
7305     state = 0xdeadbee;
7306     action = 0xdeadbee;
7307     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7308     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7309     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7310     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7311
7312     state = 0xdeadbee;
7313     action = 0xdeadbee;
7314     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7315     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7316     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7317     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7318
7319     state = 0xdeadbee;
7320     action = 0xdeadbee;
7321     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7322     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7323     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7324     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7325
7326     state = 0xdeadbee;
7327     action = 0xdeadbee;
7328     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7329     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7330     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7331     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7332
7333     state = 0xdeadbee;
7334     action = 0xdeadbee;
7335     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7336     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7337     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7338     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7339
7340     state = 0xdeadbee;
7341     action = 0xdeadbee;
7342     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7343     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7344     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7345     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7346
7347     state = 0xdeadbee;
7348     action = 0xdeadbee;
7349     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7350     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7351     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7352     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7353
7354     state = 0xdeadbee;
7355     action = 0xdeadbee;
7356     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7357     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7358     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7359     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7360
7361     state = 0xdeadbee;
7362     action = 0xdeadbee;
7363     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7364     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7365     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7366     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7367
7368     state = 0xdeadbee;
7369     action = 0xdeadbee;
7370     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7371     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7372     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7373     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7374
7375     state = 0xdeadbee;
7376     action = 0xdeadbee;
7377     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7378     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7379     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7380     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7381
7382     state = 0xdeadbee;
7383     action = 0xdeadbee;
7384     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7385     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7386     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7387     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7388
7389     state = 0xdeadbee;
7390     action = 0xdeadbee;
7391     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7392     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7393     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7394     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7395
7396     state = 0xdeadbee;
7397     action = 0xdeadbee;
7398     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7399     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7400     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7401     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7402
7403     state = 0xdeadbee;
7404     action = 0xdeadbee;
7405     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7406     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7407     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7408     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7409
7410     r = MsiDoAction( hpkg, "CostFinalize");
7411     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
7412
7413     state = 0xdeadbee;
7414     action = 0xdeadbee;
7415     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7416     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7417     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7418     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7419
7420     state = 0xdeadbee;
7421     action = 0xdeadbee;
7422     r = MsiGetFeatureState(hpkg, "two", &state, &action);
7423     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7424     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7425     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7426
7427     state = 0xdeadbee;
7428     action = 0xdeadbee;
7429     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7430     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7431     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7432     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7433
7434     state = 0xdeadbee;
7435     action = 0xdeadbee;
7436     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7437     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7438     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7439     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7440
7441     state = 0xdeadbee;
7442     action = 0xdeadbee;
7443     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7444     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7445     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7446     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7447
7448     state = 0xdeadbee;
7449     action = 0xdeadbee;
7450     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7451     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7452     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7453     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7454
7455     state = 0xdeadbee;
7456     action = 0xdeadbee;
7457     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7458     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7459     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7460     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7461
7462     state = 0xdeadbee;
7463     action = 0xdeadbee;
7464     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7465     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7466     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7467     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7468
7469     state = 0xdeadbee;
7470     action = 0xdeadbee;
7471     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7472     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7473     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7474     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7475
7476     state = 0xdeadbee;
7477     action = 0xdeadbee;
7478     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7479     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7480     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7481     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7482
7483     state = 0xdeadbee;
7484     action = 0xdeadbee;
7485     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7486     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7487     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7488     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7489
7490     state = 0xdeadbee;
7491     action = 0xdeadbee;
7492     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7493     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7494     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7495     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7496
7497     state = 0xdeadbee;
7498     action = 0xdeadbee;
7499     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7500     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7501     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7502     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7503
7504     state = 0xdeadbee;
7505     action = 0xdeadbee;
7506     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7507     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7508     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7509     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7510
7511     state = 0xdeadbee;
7512     action = 0xdeadbee;
7513     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7514     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7515     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7516     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7517
7518     state = 0xdeadbee;
7519     action = 0xdeadbee;
7520     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7521     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7522     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7523     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7524
7525     state = 0xdeadbee;
7526     action = 0xdeadbee;
7527     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7528     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7529     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7530     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7531
7532     state = 0xdeadbee;
7533     action = 0xdeadbee;
7534     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7535     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7536     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7537     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7538
7539     state = 0xdeadbee;
7540     action = 0xdeadbee;
7541     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7542     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7543     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7544     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7545
7546     state = 0xdeadbee;
7547     action = 0xdeadbee;
7548     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7549     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7550     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7551     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7552
7553     state = 0xdeadbee;
7554     action = 0xdeadbee;
7555     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7556     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7557     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7558     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7559
7560     state = 0xdeadbee;
7561     action = 0xdeadbee;
7562     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7563     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7564     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7565     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7566
7567     state = 0xdeadbee;
7568     action = 0xdeadbee;
7569     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7570     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7571     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7572     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7573
7574     state = 0xdeadbee;
7575     action = 0xdeadbee;
7576     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7577     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7578     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7579     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7580
7581     state = 0xdeadbee;
7582     action = 0xdeadbee;
7583     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7584     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7585     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7586     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7587
7588     state = 0xdeadbee;
7589     action = 0xdeadbee;
7590     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7591     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7592     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7593     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7594
7595     state = 0xdeadbee;
7596     action = 0xdeadbee;
7597     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7598     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7599     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7600     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7601
7602     state = 0xdeadbee;
7603     action = 0xdeadbee;
7604     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7605     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7606     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7607     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7608
7609     state = 0xdeadbee;
7610     action = 0xdeadbee;
7611     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7612     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7613     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7614     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7615
7616     state = 0xdeadbee;
7617     action = 0xdeadbee;
7618     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7619     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7620     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7621     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7622
7623     state = 0xdeadbee;
7624     action = 0xdeadbee;
7625     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7626     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7627     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7628     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7629
7630     state = 0xdeadbee;
7631     action = 0xdeadbee;
7632     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7633     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7634     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7635     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7636
7637     state = 0xdeadbee;
7638     action = 0xdeadbee;
7639     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7640     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7641     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7642     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7643
7644     MsiCloseHandle(hpkg);
7645
7646     /* uninstall the product */
7647     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7649
7650     DeleteFileA(msifile);
7651     DeleteFileA(msifile2);
7652     DeleteFileA(msifile3);
7653     DeleteFileA(msifile4);
7654 }
7655
7656 static void test_getproperty(void)
7657 {
7658     MSIHANDLE hPackage = 0;
7659     char prop[100];
7660     static CHAR empty[] = "";
7661     DWORD size;
7662     UINT r;
7663
7664     r = package_from_db(create_package_db(), &hPackage);
7665     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7666     {
7667         skip("Not enough rights to perform tests\n");
7668         DeleteFile(msifile);
7669         return;
7670     }
7671     ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
7672
7673     /* set the property */
7674     r = MsiSetProperty(hPackage, "Name", "Value");
7675     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7676
7677     /* retrieve the size, NULL pointer */
7678     size = 0;
7679     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7681     ok( size == 5, "Expected 5, got %d\n", size);
7682
7683     /* retrieve the size, empty string */
7684     size = 0;
7685     r = MsiGetProperty(hPackage, "Name", empty, &size);
7686     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7687     ok( size == 5, "Expected 5, got %d\n", size);
7688
7689     /* don't change size */
7690     r = MsiGetProperty(hPackage, "Name", prop, &size);
7691     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7692     ok( size == 5, "Expected 5, got %d\n", size);
7693     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7694
7695     /* increase the size by 1 */
7696     size++;
7697     r = MsiGetProperty(hPackage, "Name", prop, &size);
7698     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7699     ok( size == 5, "Expected 5, got %d\n", size);
7700     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7701
7702     r = MsiCloseHandle( hPackage);
7703     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7704     DeleteFile(msifile);
7705 }
7706
7707 static void test_removefiles(void)
7708 {
7709     MSIHANDLE hpkg;
7710     UINT r;
7711     MSIHANDLE hdb;
7712     INSTALLSTATE installed, action;
7713
7714     hdb = create_package_db();
7715     ok ( hdb, "failed to create package database\n" );
7716
7717     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7718     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7719
7720     r = create_feature_table( hdb );
7721     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7722
7723     r = create_component_table( hdb );
7724     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7725
7726     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7727     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7728
7729     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7730     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7731
7732     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7733     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7734
7735     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7736     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7737
7738     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7739     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7740
7741     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7742     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7743
7744     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7745     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7746
7747     r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
7748     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7749
7750     r = create_feature_components_table( hdb );
7751     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7752
7753     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7754     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7755
7756     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7757     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7758
7759     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7760     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7761
7762     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7763     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7764
7765     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7766     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7767
7768     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7769     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7770
7771     r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
7772     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7773
7774     r = create_file_table( hdb );
7775     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7776
7777     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7778     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7779
7780     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7781     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7782
7783     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7784     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7785
7786     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7787     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7788
7789     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7790     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7791
7792     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7793     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7794
7795     r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
7796     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7797
7798     r = create_remove_file_table( hdb );
7799     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7800
7801     r = package_from_db( hdb, &hpkg );
7802     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7803     {
7804         skip("Not enough rights to perform tests\n");
7805         DeleteFile(msifile);
7806         return;
7807     }
7808     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7809
7810     MsiCloseHandle( hdb );
7811
7812     create_test_file( "hydrogen.txt" );
7813     create_test_file( "helium.txt" );
7814     create_test_file( "lithium.txt" );
7815     create_test_file( "beryllium.txt" );
7816     create_test_file( "boron.txt" );
7817     create_test_file( "carbon.txt" );
7818     create_test_file( "oxygen.txt" );
7819
7820     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7821     ok( r == ERROR_SUCCESS, "set property failed\n");
7822
7823     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7824
7825     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7826     ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
7827
7828     r = MsiDoAction( hpkg, "CostInitialize");
7829     ok( r == ERROR_SUCCESS, "cost init failed\n");
7830
7831     r = MsiDoAction( hpkg, "FileCost");
7832     ok( r == ERROR_SUCCESS, "file cost failed\n");
7833
7834     installed = action = 0xdeadbeef;
7835     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7836     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7837     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7838     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7839
7840     r = MsiDoAction( hpkg, "CostFinalize");
7841     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7842
7843     r = MsiDoAction( hpkg, "InstallValidate");
7844     ok( r == ERROR_SUCCESS, "install validate failed\n");
7845
7846     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7847     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7848
7849     installed = action = 0xdeadbeef;
7850     r = MsiGetComponentState( hpkg, "hydrogen", &installed, &action );
7851     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7852     todo_wine {
7853     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7854     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7855     }
7856
7857     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7858     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7859
7860     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7861     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7862
7863     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7864     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7865
7866     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7867     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7868
7869     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7870     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7871
7872     installed = action = 0xdeadbeef;
7873     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7874     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7875     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7876     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7877
7878     r = MsiSetComponentState( hpkg, "oxygen", INSTALLSTATE_ABSENT );
7879     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7880
7881     installed = action = 0xdeadbeef;
7882     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7883     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7884     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7885     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7886
7887     r = MsiDoAction( hpkg, "RemoveFiles");
7888     ok( r == ERROR_SUCCESS, "remove files failed\n");
7889
7890     installed = action = 0xdeadbeef;
7891     r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
7892     ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
7893     ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
7894     ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
7895
7896     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7897     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7898     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7899     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7900     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7901     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7902     ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
7903
7904     MsiCloseHandle( hpkg );
7905     DeleteFileA(msifile);
7906 }
7907
7908 static void test_appsearch(void)
7909 {
7910     MSIHANDLE hpkg;
7911     UINT r;
7912     MSIHANDLE hdb;
7913     CHAR prop[MAX_PATH];
7914     DWORD size;
7915
7916     hdb = create_package_db();
7917     ok ( hdb, "failed to create package database\n" );
7918
7919     r = create_appsearch_table( hdb );
7920     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7921
7922     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7923     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7924
7925     r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
7926     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7927
7928     r = create_reglocator_table( hdb );
7929     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7930
7931     r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
7932     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7933
7934     r = create_drlocator_table( hdb );
7935     ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
7936
7937     r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
7938     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7939
7940     r = create_signature_table( hdb );
7941     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7942
7943     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7944     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7945
7946     r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
7947     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7948
7949     r = package_from_db( hdb, &hpkg );
7950     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7951     {
7952         skip("Not enough rights to perform tests\n");
7953         DeleteFile(msifile);
7954         return;
7955     }
7956     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7957     MsiCloseHandle( hdb );
7958     if (r != ERROR_SUCCESS)
7959         goto done;
7960
7961     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7962
7963     r = MsiDoAction( hpkg, "AppSearch" );
7964     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7965
7966     size = sizeof(prop);
7967     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7968     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7969     todo_wine
7970     {
7971         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7972     }
7973
7974     size = sizeof(prop);
7975     r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
7976     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7977
7978 done:
7979     MsiCloseHandle( hpkg );
7980     DeleteFileA(msifile);
7981 }
7982
7983 static void test_appsearch_complocator(void)
7984 {
7985     MSIHANDLE hpkg, hdb;
7986     CHAR path[MAX_PATH];
7987     CHAR prop[MAX_PATH];
7988     LPSTR usersid;
7989     DWORD size;
7990     UINT r;
7991
7992     if (!get_user_sid(&usersid))
7993         return;
7994
7995     if (is_process_limited())
7996     {
7997         skip("process is limited\n");
7998         return;
7999     }
8000
8001     create_test_file("FileName1");
8002     create_test_file("FileName4");
8003     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
8004                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
8005
8006     create_test_file("FileName2");
8007     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
8008                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
8009
8010     create_test_file("FileName3");
8011     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
8012                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
8013
8014     create_test_file("FileName5");
8015     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
8016                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
8017
8018     create_test_file("FileName6");
8019     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
8020                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
8021
8022     create_test_file("FileName7");
8023     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
8024                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
8025
8026     /* dir is FALSE, but we're pretending it's a directory */
8027     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
8028                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
8029
8030     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8031     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
8032                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
8033
8034     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8035     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
8036                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
8037
8038     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8039     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
8040                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
8041
8042     hdb = create_package_db();
8043     ok(hdb, "Expected a valid database handle\n");
8044
8045     r = create_appsearch_table(hdb);
8046     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8047
8048     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8049     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8050
8051     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8052     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8053
8054     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8056
8057     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8058     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8059
8060     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8061     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8062
8063     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8064     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8065
8066     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8067     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8068
8069     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8070     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8071
8072     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8073     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8074
8075     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8076     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8077
8078     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8079     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8080
8081     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8082     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8083
8084     r = create_complocator_table(hdb);
8085     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8086
8087     /* published component, machine, file, signature, misdbLocatorTypeFile */
8088     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
8089     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8090
8091     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
8092     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
8093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8094
8095     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
8096     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
8097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8098
8099     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
8100     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
8101     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8102
8103     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
8104     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
8105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8106
8107     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
8108     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
8109     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8110
8111     /* published component, machine, file, no signature, misdbLocatorTypeFile */
8112     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
8113     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8114
8115     /* unpublished component, no signature, misdbLocatorTypeDir */
8116     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
8117     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8118
8119     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
8120     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
8121     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8122
8123     /* published component, signature w/ ver, misdbLocatorTypeFile */
8124     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
8125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8126
8127     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
8128     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
8129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8130
8131     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
8132     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
8133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8134
8135     r = create_signature_table(hdb);
8136     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8137
8138     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
8139     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8140
8141     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
8142     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8143
8144     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
8145     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8146
8147     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
8148     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8149
8150     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
8151     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8152
8153     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8154     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8155
8156     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8157     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8158
8159     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8160     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8161
8162     r = package_from_db(hdb, &hpkg);
8163     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8164     {
8165         skip("Not enough rights to perform tests\n");
8166         goto error;
8167     }
8168     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8169
8170     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
8171     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172
8173     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8174
8175     r = MsiDoAction(hpkg, "AppSearch");
8176     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8177
8178     size = MAX_PATH;
8179     sprintf(path, "%s\\FileName1", CURR_DIR);
8180     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8181     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8182     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8183
8184     size = MAX_PATH;
8185     sprintf(path, "%s\\FileName2", CURR_DIR);
8186     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8187     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8188     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8189
8190     size = MAX_PATH;
8191     sprintf(path, "%s\\FileName3", CURR_DIR);
8192     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8193     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8194     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8195
8196     size = MAX_PATH;
8197     sprintf(path, "%s\\FileName4", CURR_DIR);
8198     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8199     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8200     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8201
8202     size = MAX_PATH;
8203     sprintf(path, "%s\\FileName5", CURR_DIR);
8204     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8205     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8206     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8207
8208     size = MAX_PATH;
8209     sprintf(path, "%s\\", CURR_DIR);
8210     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8211     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8212     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8213
8214     size = MAX_PATH;
8215     sprintf(path, "%s\\", CURR_DIR);
8216     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8217     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8218     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8219
8220     size = MAX_PATH;
8221     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8222     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8223     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
8224
8225     size = MAX_PATH;
8226     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8227     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8228     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8229
8230     size = MAX_PATH;
8231     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
8232     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8233     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8234     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8235
8236     size = MAX_PATH;
8237     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8238     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8239     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8240
8241     size = MAX_PATH;
8242     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
8243     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8244     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8245     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8246
8247     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
8248                           MSIINSTALLCONTEXT_MACHINE, NULL);
8249     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
8250                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
8251     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
8252                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
8253     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
8254                           MSIINSTALLCONTEXT_MACHINE, NULL);
8255     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
8256                           MSIINSTALLCONTEXT_MACHINE, NULL);
8257     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
8258                           MSIINSTALLCONTEXT_MACHINE, NULL);
8259     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
8260                           MSIINSTALLCONTEXT_MACHINE, NULL);
8261     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
8262                           MSIINSTALLCONTEXT_MACHINE, NULL);
8263     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
8264                           MSIINSTALLCONTEXT_MACHINE, NULL);
8265     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
8266                           MSIINSTALLCONTEXT_MACHINE, NULL);
8267
8268     MsiCloseHandle(hpkg);
8269
8270 error:
8271     DeleteFileA("FileName1");
8272     DeleteFileA("FileName2");
8273     DeleteFileA("FileName3");
8274     DeleteFileA("FileName4");
8275     DeleteFileA("FileName5");
8276     DeleteFileA("FileName6");
8277     DeleteFileA("FileName7");
8278     DeleteFileA("FileName8.dll");
8279     DeleteFileA("FileName9.dll");
8280     DeleteFileA("FileName10.dll");
8281     DeleteFileA(msifile);
8282     LocalFree(usersid);
8283 }
8284
8285 static void test_appsearch_reglocator(void)
8286 {
8287     MSIHANDLE hpkg, hdb;
8288     CHAR path[MAX_PATH], prop[MAX_PATH];
8289     DWORD binary[2], size, val;
8290     BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
8291     HKEY hklm, classes, hkcu, users;
8292     LPSTR pathdata, pathvar, ptr;
8293     LPCSTR str;
8294     LONG res;
8295     UINT r, type = 0;
8296     SYSTEM_INFO si;
8297
8298     version = TRUE;
8299     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8300         version = FALSE;
8301
8302     DeleteFileA("test.dll");
8303
8304     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
8305     if (res == ERROR_ACCESS_DENIED)
8306     {
8307         skip("Not enough rights to perform tests\n");
8308         return;
8309     }
8310     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8311
8312     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
8313                          (const BYTE *)"regszdata", 10);
8314     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8315
8316     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
8317     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8318
8319     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
8320                          (const BYTE *)"regszdata", 10);
8321     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8322
8323     users = 0;
8324     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
8325     ok(res == ERROR_SUCCESS ||
8326        broken(res == ERROR_INVALID_PARAMETER),
8327        "Expected ERROR_SUCCESS, got %d\n", res);
8328
8329     if (res == ERROR_SUCCESS)
8330     {
8331         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
8332                              (const BYTE *)"regszdata", 10);
8333         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8334     }
8335
8336     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
8337     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8338
8339     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
8340     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8341
8342     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
8343                          (const BYTE *)"regszdata", 10);
8344     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8345
8346     val = 42;
8347     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
8348                          (const BYTE *)&val, sizeof(DWORD));
8349     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8350
8351     val = -42;
8352     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
8353                          (const BYTE *)&val, sizeof(DWORD));
8354     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8355
8356     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
8357                          (const BYTE *)"%PATH%", 7);
8358     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8359
8360     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
8361                          (const BYTE *)"my%NOVAR%", 10);
8362     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8363
8364     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
8365                          (const BYTE *)"one\0two\0", 9);
8366     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8367
8368     binary[0] = 0x1234abcd;
8369     binary[1] = 0x567890ef;
8370     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
8371                          (const BYTE *)binary, sizeof(binary));
8372     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8373
8374     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
8375                          (const BYTE *)"#regszdata", 11);
8376     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8377
8378     create_test_file("FileName1");
8379     sprintf(path, "%s\\FileName1", CURR_DIR);
8380     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
8381                          (const BYTE *)path, lstrlenA(path) + 1);
8382     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8383
8384     sprintf(path, "%s\\FileName2", CURR_DIR);
8385     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
8386                          (const BYTE *)path, lstrlenA(path) + 1);
8387     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8388
8389     lstrcpyA(path, CURR_DIR);
8390     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
8391                          (const BYTE *)path, lstrlenA(path) + 1);
8392     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8393
8394     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
8395                          (const BYTE *)"", 1);
8396     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8397
8398     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8399     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8400     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
8401                          (const BYTE *)path, lstrlenA(path) + 1);
8402     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8403
8404     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8405     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8406     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
8407                          (const BYTE *)path, lstrlenA(path) + 1);
8408     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8409
8410     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8411     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8412     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
8413                          (const BYTE *)path, lstrlenA(path) + 1);
8414     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8415
8416     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
8417     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
8418                          (const BYTE *)path, lstrlenA(path) + 1);
8419
8420     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
8421     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
8422     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
8423                          (const BYTE *)path, lstrlenA(path) + 1);
8424
8425     hdb = create_package_db();
8426     ok(hdb, "Expected a valid database handle\n");
8427
8428     r = create_appsearch_table(hdb);
8429     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8430
8431     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8432     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8433
8434     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8436
8437     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8438     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8439
8440     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8441     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8442
8443     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8444     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8445
8446     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8447     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8448
8449     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8451
8452     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8453     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8454
8455     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8457
8458     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8460
8461     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8463
8464     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8466
8467     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8468     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8469
8470     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
8471     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8472
8473     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
8474     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8475
8476     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
8477     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8478
8479     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
8480     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8481
8482     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
8483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8484
8485     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
8486     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8487
8488     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
8489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8490
8491     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
8492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8493
8494     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
8495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8496
8497     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
8498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8499
8500     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
8501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8502
8503     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
8504     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8505
8506     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
8507     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8508
8509     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
8510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8511
8512     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
8513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8514
8515     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
8516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8517
8518     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
8519     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8520
8521     r = create_reglocator_table(hdb);
8522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8523
8524     type = msidbLocatorTypeRawValue;
8525     if (is_64bit)
8526         type |= msidbLocatorType64bit;
8527
8528     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
8529     r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
8530     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8531
8532     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
8533     r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
8534     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8535
8536     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
8537     r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
8538     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8539
8540     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8541     r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
8542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8543
8544     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8545     r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
8546     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8547
8548     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
8549     r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
8550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8551
8552     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
8553     r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
8554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8555
8556     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
8557     r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
8558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8559
8560     type = msidbLocatorTypeFileName;
8561     if (is_64bit)
8562         type |= msidbLocatorType64bit;
8563
8564     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
8565     r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
8566     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8567
8568     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
8569     r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
8570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8571
8572     /* HKLM, msidbLocatorTypeFileName, no signature */
8573     r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
8574     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8575
8576     type = msidbLocatorTypeDirectory;
8577     if (is_64bit)
8578         type |= msidbLocatorType64bit;
8579
8580     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
8581     r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
8582     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8583
8584     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
8585     r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
8586     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8587
8588     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
8589     r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
8590     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8591
8592     type = msidbLocatorTypeRawValue;
8593     if (is_64bit)
8594         type |= msidbLocatorType64bit;
8595
8596     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
8597     r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
8598     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8599
8600     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
8601     r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
8602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8603
8604     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
8605     r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
8606     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8607
8608     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
8609     r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
8610     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8611
8612     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
8613     r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
8614     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8615
8616     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
8617     r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
8618     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8619
8620     type = msidbLocatorTypeFileName;
8621     if (is_64bit)
8622         type |= msidbLocatorType64bit;
8623
8624     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
8625     r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
8626     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8627
8628     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
8629     r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
8630     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8631
8632     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
8633     r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
8634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8635
8636     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
8637     r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
8638     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8639
8640     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
8641     r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
8642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8643
8644     type = msidbLocatorTypeDirectory;
8645     if (is_64bit)
8646         type |= msidbLocatorType64bit;
8647
8648     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8649     r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
8650     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8651
8652     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8653     r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
8654     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8655
8656     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8657     r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
8658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8659
8660     type = msidbLocatorTypeFileName;
8661     if (is_64bit)
8662         type |= msidbLocatorType64bit;
8663
8664     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8665     r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
8666     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8667
8668     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8669     r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
8670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8671
8672     r = create_signature_table(hdb);
8673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8674
8675     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8676     r = add_signature_entry(hdb, str);
8677     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8678
8679     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8680     r = add_signature_entry(hdb, str);
8681     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8682
8683     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8684     r = add_signature_entry(hdb, str);
8685     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8686
8687     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8688     r = add_signature_entry(hdb, str);
8689     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8690
8691     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8692     r = add_signature_entry(hdb, str);
8693     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8694
8695     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8696     r = add_signature_entry(hdb, str);
8697     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8698
8699     ptr = strrchr(CURR_DIR, '\\') + 1;
8700     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8701     r = add_signature_entry(hdb, path);
8702     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8703
8704     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8705     r = add_signature_entry(hdb, str);
8706     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8707
8708     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8709     r = add_signature_entry(hdb, str);
8710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8711
8712     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8713     r = add_signature_entry(hdb, str);
8714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8715
8716     r = package_from_db(hdb, &hpkg);
8717     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8718
8719     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8720
8721     r = MsiDoAction(hpkg, "AppSearch");
8722     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8723
8724     size = MAX_PATH;
8725     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8726     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8727     ok(!lstrcmpA(prop, "regszdata"),
8728        "Expected \"regszdata\", got \"%s\"\n", prop);
8729
8730     size = MAX_PATH;
8731     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8732     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8733     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8734
8735     size = MAX_PATH;
8736     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8737     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8738     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8739
8740     memset(&si, 0, sizeof(si));
8741     if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
8742
8743     if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
8744     {
8745         size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8746         if (size == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
8747         {
8748             /* Workaround for Win95 */
8749             CHAR tempbuf[1];
8750             size = ExpandEnvironmentStringsA("%PATH%", tempbuf, 0);
8751         }
8752         pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8753         ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8754
8755         size = 0;
8756         r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8757         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8758
8759         pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8760         r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8761         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8762         ok(!lstrcmpA(pathdata, pathvar),
8763             "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8764
8765         HeapFree(GetProcessHeap(), 0, pathvar);
8766         HeapFree(GetProcessHeap(), 0, pathdata);
8767     }
8768
8769     size = MAX_PATH;
8770     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8772     ok(!lstrcmpA(prop,
8773        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8774
8775     size = MAX_PATH;
8776     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8777     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8778     todo_wine
8779     {
8780         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8781            "Expected \"\\0one\\0two\\0\\0\"\n");
8782     }
8783
8784     size = MAX_PATH;
8785     lstrcpyA(path, "#xCDAB3412EF907856");
8786     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8787     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8788     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8789
8790     size = MAX_PATH;
8791     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8793     ok(!lstrcmpA(prop, "##regszdata"),
8794        "Expected \"##regszdata\", got \"%s\"\n", prop);
8795
8796     size = MAX_PATH;
8797     sprintf(path, "%s\\FileName1", CURR_DIR);
8798     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8799     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8800     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8801
8802     size = MAX_PATH;
8803     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8804     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8805     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8806
8807     size = MAX_PATH;
8808     sprintf(path, "%s\\", CURR_DIR);
8809     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8811     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8812
8813     size = MAX_PATH;
8814     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8815     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8816     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8817
8818     size = MAX_PATH;
8819     sprintf(path, "%s\\", CURR_DIR);
8820     r = MsiGetPropertyA(hpkg, "SIGPROP13", 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, "SIGPROP14", 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     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8832     ok(!lstrcmpA(prop, "regszdata"),
8833        "Expected \"regszdata\", got \"%s\"\n", prop);
8834
8835     size = MAX_PATH;
8836     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8838     ok(!lstrcmpA(prop, "regszdata"),
8839        "Expected \"regszdata\", got \"%s\"\n", prop);
8840
8841     if (users)
8842     {
8843         size = MAX_PATH;
8844         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8845         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8846         ok(!lstrcmpA(prop, "regszdata"),
8847            "Expected \"regszdata\", got \"%s\"\n", prop);
8848     }
8849
8850     size = MAX_PATH;
8851     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8853     ok(!lstrcmpA(prop, "defvalue"),
8854        "Expected \"defvalue\", got \"%s\"\n", prop);
8855
8856     size = MAX_PATH;
8857     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8859     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8860
8861     size = MAX_PATH;
8862     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
8863     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8864     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8865
8866     if (version)
8867     {
8868         size = MAX_PATH;
8869         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8870         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8871         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8872         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8873
8874         size = MAX_PATH;
8875         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8876         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8877         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8878
8879         size = MAX_PATH;
8880         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8881         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8882         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8883         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8884     }
8885
8886     size = MAX_PATH;
8887     lstrcpyA(path, CURR_DIR);
8888     ptr = strrchr(path, '\\') + 1;
8889     *ptr = '\0';
8890     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8892     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8893
8894     size = MAX_PATH;
8895     sprintf(path, "%s\\", CURR_DIR);
8896     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8897     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8898     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8899
8900     size = MAX_PATH;
8901     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8902     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8903     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8904
8905     size = MAX_PATH;
8906     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8907     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8908     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8909
8910     size = MAX_PATH;
8911     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8913     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8914
8915     size = MAX_PATH;
8916     sprintf(path, "%s\\FileName1", CURR_DIR);
8917     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8918     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8919     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8920
8921     size = MAX_PATH;
8922     sprintf(path, "%s\\FileName1", CURR_DIR);
8923     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8924     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8925     if (space)
8926         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8927     else
8928         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8929
8930     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8931     RegDeleteValueA(hklm, "Value1");
8932     RegDeleteValueA(hklm, "Value2");
8933     RegDeleteValueA(hklm, "Value3");
8934     RegDeleteValueA(hklm, "Value4");
8935     RegDeleteValueA(hklm, "Value5");
8936     RegDeleteValueA(hklm, "Value6");
8937     RegDeleteValueA(hklm, "Value7");
8938     RegDeleteValueA(hklm, "Value8");
8939     RegDeleteValueA(hklm, "Value9");
8940     RegDeleteValueA(hklm, "Value10");
8941     RegDeleteValueA(hklm, "Value11");
8942     RegDeleteValueA(hklm, "Value12");
8943     RegDeleteValueA(hklm, "Value13");
8944     RegDeleteValueA(hklm, "Value14");
8945     RegDeleteValueA(hklm, "Value15");
8946     RegDeleteValueA(hklm, "Value16");
8947     RegDeleteValueA(hklm, "Value17");
8948     RegDeleteKey(hklm, "");
8949     RegCloseKey(hklm);
8950
8951     RegDeleteValueA(classes, "Value1");
8952     RegDeleteKeyA(classes, "");
8953     RegCloseKey(classes);
8954
8955     RegDeleteValueA(hkcu, "Value1");
8956     RegDeleteKeyA(hkcu, "");
8957     RegCloseKey(hkcu);
8958
8959     RegDeleteValueA(users, "Value1");
8960     RegDeleteKeyA(users, "");
8961     RegCloseKey(users);
8962
8963     DeleteFileA("FileName1");
8964     DeleteFileA("FileName3.dll");
8965     DeleteFileA("FileName4.dll");
8966     DeleteFileA("FileName5.dll");
8967     MsiCloseHandle(hpkg);
8968     DeleteFileA(msifile);
8969 }
8970
8971 static void delete_win_ini(LPCSTR file)
8972 {
8973     CHAR path[MAX_PATH];
8974
8975     GetWindowsDirectoryA(path, MAX_PATH);
8976     lstrcatA(path, "\\");
8977     lstrcatA(path, file);
8978
8979     DeleteFileA(path);
8980 }
8981
8982 static void test_appsearch_inilocator(void)
8983 {
8984     MSIHANDLE hpkg, hdb;
8985     CHAR path[MAX_PATH];
8986     CHAR prop[MAX_PATH];
8987     BOOL version;
8988     LPCSTR str;
8989     LPSTR ptr;
8990     DWORD size;
8991     UINT r;
8992
8993     version = TRUE;
8994     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8995         version = FALSE;
8996
8997     DeleteFileA("test.dll");
8998
8999     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
9000
9001     create_test_file("FileName1");
9002     sprintf(path, "%s\\FileName1", CURR_DIR);
9003     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
9004
9005     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
9006
9007     sprintf(path, "%s\\IDontExist", CURR_DIR);
9008     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
9009
9010     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9011     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
9012     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
9013
9014     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
9015     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9016     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
9017
9018     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9019     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
9020     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
9021
9022     hdb = create_package_db();
9023     ok(hdb, "Expected a valid database handle\n");
9024
9025     r = create_appsearch_table(hdb);
9026     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9027
9028     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
9029     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9030
9031     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
9032     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9033
9034     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
9035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9036
9037     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
9038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9039
9040     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
9041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9042
9043     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
9044     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9045
9046     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
9047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9048
9049     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
9050     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9051
9052     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
9053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9054
9055     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
9056     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9057
9058     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
9059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9060
9061     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
9062     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9063
9064     r = create_inilocator_table(hdb);
9065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9066
9067     /* msidbLocatorTypeRawValue, field 1 */
9068     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
9069     r = add_inilocator_entry(hdb, str);
9070     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9071
9072     /* msidbLocatorTypeRawValue, field 2 */
9073     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
9074     r = add_inilocator_entry(hdb, str);
9075     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9076
9077     /* msidbLocatorTypeRawValue, entire field */
9078     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
9079     r = add_inilocator_entry(hdb, str);
9080     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9081
9082     /* msidbLocatorTypeFile */
9083     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
9084     r = add_inilocator_entry(hdb, str);
9085     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9086
9087     /* msidbLocatorTypeDirectory, file */
9088     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
9089     r = add_inilocator_entry(hdb, str);
9090     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9091
9092     /* msidbLocatorTypeDirectory, directory */
9093     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
9094     r = add_inilocator_entry(hdb, str);
9095     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9096
9097     /* msidbLocatorTypeFile, file, no signature */
9098     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
9099     r = add_inilocator_entry(hdb, str);
9100     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9101
9102     /* msidbLocatorTypeFile, dir, no signature */
9103     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
9104     r = add_inilocator_entry(hdb, str);
9105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9106
9107     /* msidbLocatorTypeFile, file does not exist */
9108     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
9109     r = add_inilocator_entry(hdb, str);
9110     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9111
9112     /* msidbLocatorTypeFile, signature with version */
9113     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
9114     r = add_inilocator_entry(hdb, str);
9115     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9116
9117     /* msidbLocatorTypeFile, signature with version, ver > max */
9118     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
9119     r = add_inilocator_entry(hdb, str);
9120     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9121
9122     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
9123     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
9124     r = add_inilocator_entry(hdb, str);
9125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9126
9127     r = create_signature_table(hdb);
9128     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9129
9130     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
9131     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9132
9133     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
9134     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9135
9136     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9138
9139     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9140     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9141
9142     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9143     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9144
9145     r = package_from_db(hdb, &hpkg);
9146     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9147     {
9148         skip("Not enough rights to perform tests\n");
9149         goto error;
9150     }
9151     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9152
9153     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9154
9155     r = MsiDoAction(hpkg, "AppSearch");
9156     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9157
9158     size = MAX_PATH;
9159     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9160     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9161     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
9162
9163     size = MAX_PATH;
9164     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9166     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
9167
9168     size = MAX_PATH;
9169     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9170     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9171     ok(!lstrcmpA(prop, "keydata,field2"),
9172        "Expected \"keydata,field2\", got \"%s\"\n", prop);
9173
9174     size = MAX_PATH;
9175     sprintf(path, "%s\\FileName1", CURR_DIR);
9176     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9177     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9178     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9179
9180     size = MAX_PATH;
9181     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9182     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9183     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9184
9185     size = MAX_PATH;
9186     sprintf(path, "%s\\", CURR_DIR);
9187     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9188     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9189     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9190
9191     size = MAX_PATH;
9192     sprintf(path, "%s\\", CURR_DIR);
9193     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9194     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9195     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9196
9197     size = MAX_PATH;
9198     lstrcpyA(path, CURR_DIR);
9199     ptr = strrchr(path, '\\');
9200     *(ptr + 1) = '\0';
9201     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9202     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9203     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9204
9205     size = MAX_PATH;
9206     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9207     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9208     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9209
9210     if (version)
9211     {
9212         size = MAX_PATH;
9213         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
9214         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9215         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9216         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9217
9218         size = MAX_PATH;
9219         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9220         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9221         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9222
9223         size = MAX_PATH;
9224         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
9225         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
9226         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9227         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9228     }
9229
9230     MsiCloseHandle(hpkg);
9231
9232 error:
9233     delete_win_ini("IniFile.ini");
9234     DeleteFileA("FileName1");
9235     DeleteFileA("FileName2.dll");
9236     DeleteFileA("FileName3.dll");
9237     DeleteFileA("FileName4.dll");
9238     DeleteFileA(msifile);
9239 }
9240
9241 /*
9242  * MSI AppSearch action on DrLocator table always returns absolute paths.
9243  * If a relative path was set, it returns the first absolute path that
9244  * matches or an empty string if it didn't find anything.
9245  * This helper function replicates this behaviour.
9246  */
9247 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
9248 {
9249     int i, size;
9250     DWORD attr, drives;
9251
9252     size = lstrlenA(relative);
9253     drives = GetLogicalDrives();
9254     lstrcpyA(absolute, "A:\\");
9255     for (i = 0; i < 26; absolute[0] = '\0', i++)
9256     {
9257         if (!(drives & (1 << i)))
9258             continue;
9259
9260         absolute[0] = 'A' + i;
9261         if (GetDriveType(absolute) != DRIVE_FIXED)
9262             continue;
9263
9264         lstrcpynA(absolute + 3, relative, size + 1);
9265         attr = GetFileAttributesA(absolute);
9266         if (attr != INVALID_FILE_ATTRIBUTES &&
9267             (attr & FILE_ATTRIBUTE_DIRECTORY))
9268         {
9269             if (absolute[3 + size - 1] != '\\')
9270                 lstrcatA(absolute, "\\");
9271             break;
9272         }
9273         absolute[3] = '\0';
9274     }
9275 }
9276
9277 static void test_appsearch_drlocator(void)
9278 {
9279     MSIHANDLE hpkg, hdb;
9280     CHAR path[MAX_PATH];
9281     CHAR prop[MAX_PATH];
9282     BOOL version;
9283     LPCSTR str;
9284     DWORD size;
9285     UINT r;
9286
9287     version = TRUE;
9288     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
9289         version = FALSE;
9290
9291     DeleteFileA("test.dll");
9292
9293     create_test_file("FileName1");
9294     CreateDirectoryA("one", NULL);
9295     CreateDirectoryA("one\\two", NULL);
9296     CreateDirectoryA("one\\two\\three", NULL);
9297     create_test_file("one\\two\\three\\FileName2");
9298     CreateDirectoryA("another", NULL);
9299     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9300     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
9301     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9302
9303     hdb = create_package_db();
9304     ok(hdb, "Expected a valid database handle\n");
9305
9306     r = create_appsearch_table(hdb);
9307     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9308
9309     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
9310     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9311
9312     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
9313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9314
9315     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
9316     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9317
9318     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
9319     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9320
9321     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
9322     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9323
9324     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
9325     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9326
9327     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
9328     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9329
9330     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
9331     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9332
9333     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
9334     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9335
9336     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
9337     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9338
9339     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
9340     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9341
9342     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
9343     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9344
9345     r = create_drlocator_table(hdb);
9346     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9347
9348     /* no parent, full path, depth 0, signature */
9349     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
9350     r = add_drlocator_entry(hdb, path);
9351     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9352
9353     /* no parent, full path, depth 0, no signature */
9354     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
9355     r = add_drlocator_entry(hdb, path);
9356     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9357
9358     /* no parent, relative path, depth 0, no signature */
9359     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
9360     r = add_drlocator_entry(hdb, path);
9361     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9362
9363     /* no parent, full path, depth 2, signature */
9364     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
9365     r = add_drlocator_entry(hdb, path);
9366     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9367
9368     /* no parent, full path, depth 3, signature */
9369     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
9370     r = add_drlocator_entry(hdb, path);
9371     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9372
9373     /* no parent, full path, depth 1, signature is dir */
9374     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
9375     r = add_drlocator_entry(hdb, path);
9376     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9377
9378     /* parent is in DrLocator, relative path, depth 0, signature */
9379     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
9380     r = add_drlocator_entry(hdb, path);
9381     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9382
9383     /* no parent, full path, depth 0, signature w/ version */
9384     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
9385     r = add_drlocator_entry(hdb, path);
9386     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9387
9388     /* no parent, full path, depth 0, signature w/ version, ver > max */
9389     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
9390     r = add_drlocator_entry(hdb, path);
9391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9392
9393     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
9394     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
9395     r = add_drlocator_entry(hdb, path);
9396     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9397
9398     /* no parent, relative empty path, depth 0, no signature */
9399     sprintf(path, "'NewSignature11', '', '', 0");
9400     r = add_drlocator_entry(hdb, path);
9401     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9402
9403     r = create_reglocator_table(hdb);
9404     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9405
9406     /* parent */
9407     r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
9408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9409
9410     /* parent is in RegLocator, no path, depth 0, no signature */
9411     sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
9412     r = add_drlocator_entry(hdb, path);
9413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9414
9415     r = create_signature_table(hdb);
9416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9417
9418     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
9419     r = add_signature_entry(hdb, str);
9420     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9421
9422     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
9423     r = add_signature_entry(hdb, str);
9424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9425
9426     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
9427     r = add_signature_entry(hdb, str);
9428     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9429
9430     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
9431     r = add_signature_entry(hdb, str);
9432     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9433
9434     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
9435     r = add_signature_entry(hdb, str);
9436     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9437
9438     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9439     r = add_signature_entry(hdb, str);
9440     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9441
9442     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9443     r = add_signature_entry(hdb, str);
9444     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9445
9446     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9447     r = add_signature_entry(hdb, str);
9448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9449
9450     r = package_from_db(hdb, &hpkg);
9451     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9452     {
9453         skip("Not enough rights to perform tests\n");
9454         goto error;
9455     }
9456     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9457
9458     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9459
9460     r = MsiDoAction(hpkg, "AppSearch");
9461     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9462
9463     size = MAX_PATH;
9464     sprintf(path, "%s\\FileName1", CURR_DIR);
9465     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9467     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9468
9469     size = MAX_PATH;
9470     sprintf(path, "%s\\", CURR_DIR);
9471     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9472     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9473     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9474
9475     size = MAX_PATH;
9476     search_absolute_directory(path, CURR_DIR + 3);
9477     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9478     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9479     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9480
9481     size = MAX_PATH;
9482     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9484     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9485
9486     size = MAX_PATH;
9487     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9488     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9490     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9491
9492     size = MAX_PATH;
9493     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9494     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9495     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9496
9497     size = MAX_PATH;
9498     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9499     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9501     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9502
9503     if (version)
9504     {
9505         size = MAX_PATH;
9506         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9507         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9508         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9509         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9510
9511         size = MAX_PATH;
9512         r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9513         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9514         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9515
9516         size = MAX_PATH;
9517         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9518         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9519         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9520     }
9521
9522     size = MAX_PATH;
9523     search_absolute_directory(path, "");
9524     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9526     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9527
9528     size = MAX_PATH;
9529     strcpy(path, "c:\\");
9530     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
9531     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9532     ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
9533
9534     MsiCloseHandle(hpkg);
9535
9536 error:
9537     DeleteFileA("FileName1");
9538     DeleteFileA("FileName3.dll");
9539     DeleteFileA("FileName4.dll");
9540     DeleteFileA("FileName5.dll");
9541     DeleteFileA("one\\two\\three\\FileName2");
9542     RemoveDirectoryA("one\\two\\three");
9543     RemoveDirectoryA("one\\two");
9544     RemoveDirectoryA("one");
9545     RemoveDirectoryA("another");
9546     DeleteFileA(msifile);
9547 }
9548
9549 static void test_featureparents(void)
9550 {
9551     MSIHANDLE hpkg;
9552     UINT r;
9553     MSIHANDLE hdb;
9554     INSTALLSTATE state, action;
9555
9556     hdb = create_package_db();
9557     ok ( hdb, "failed to create package database\n" );
9558
9559     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
9560     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
9561
9562     r = create_feature_table( hdb );
9563     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
9564
9565     r = create_component_table( hdb );
9566     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
9567
9568     r = create_feature_components_table( hdb );
9569     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
9570
9571     r = create_file_table( hdb );
9572     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
9573
9574     /* msidbFeatureAttributesFavorLocal */
9575     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
9576     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9577
9578     /* msidbFeatureAttributesFavorSource */
9579     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
9580     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9581
9582     /* msidbFeatureAttributesFavorLocal */
9583     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
9584     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9585
9586     /* msidbFeatureAttributesUIDisallowAbsent */
9587     r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
9588     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9589
9590     /* disabled because of install level */
9591     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
9592     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9593
9594     /* child feature of disabled feature */
9595     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
9596     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9597
9598     /* component of disabled feature (install level) */
9599     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
9600     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9601
9602     /* component of disabled child feature (install level) */
9603     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
9604     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9605
9606     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9607     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
9608     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9609
9610     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9611     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
9612     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9613
9614     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9615     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
9616     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9617
9618     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
9619     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
9620     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9621
9622     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
9623     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
9624     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9625
9626     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
9627     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
9628     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9629
9630     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9631     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
9632     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9633
9634     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9635     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
9636     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9637
9638     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9639     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
9640
9641     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
9642     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9643
9644     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
9645     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9646
9647     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
9648     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9649
9650     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
9651     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9652
9653     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
9654     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9655
9656     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
9657     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9658
9659     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
9660     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9661
9662     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
9663     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9664
9665     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
9666     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9667
9668     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
9669     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9670
9671     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
9672     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9673
9674     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
9675     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9676
9677     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
9678     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9679
9680     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
9681     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9682
9683     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
9684     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9685
9686     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
9687     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9688
9689     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
9690     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9691
9692     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
9693     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9694
9695     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
9696     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9697
9698     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9699     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9700
9701     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9702     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9703
9704     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9705     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9706
9707     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9708     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9709
9710     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9711     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9712
9713     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9714     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9715
9716     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9717     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9718
9719     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9720     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9721
9722     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9723     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9724
9725     r = package_from_db( hdb, &hpkg );
9726     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9727     {
9728         skip("Not enough rights to perform tests\n");
9729         DeleteFile(msifile);
9730         return;
9731     }
9732     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9733
9734     MsiCloseHandle( hdb );
9735
9736     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9737
9738     r = MsiDoAction( hpkg, "CostInitialize");
9739     ok( r == ERROR_SUCCESS, "cost init failed\n");
9740
9741     r = MsiDoAction( hpkg, "FileCost");
9742     ok( r == ERROR_SUCCESS, "file cost failed\n");
9743
9744     r = MsiDoAction( hpkg, "CostFinalize");
9745     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9746
9747     state = 0xdeadbee;
9748     action = 0xdeadbee;
9749     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9750     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9751     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9752     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9753
9754     state = 0xdeadbee;
9755     action = 0xdeadbee;
9756     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9757     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9758     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9759     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9760
9761     state = 0xdeadbee;
9762     action = 0xdeadbee;
9763     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9764     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9765     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9766     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9767
9768     state = 0xdeadbee;
9769     action = 0xdeadbee;
9770     r = MsiGetFeatureState(hpkg, "lyra", &state, &action);
9771     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9772     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9773     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9774
9775     state = 0xdeadbee;
9776     action = 0xdeadbee;
9777     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9778     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9779     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9780     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9781
9782     state = 0xdeadbee;
9783     action = 0xdeadbee;
9784     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9785     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9786     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9787     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9788
9789     state = 0xdeadbee;
9790     action = 0xdeadbee;
9791     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9792     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9793     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9794     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9795
9796     state = 0xdeadbee;
9797     action = 0xdeadbee;
9798     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9799     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9800     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9801     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9802
9803     state = 0xdeadbee;
9804     action = 0xdeadbee;
9805     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9806     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9807     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9808     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9809
9810     state = 0xdeadbee;
9811     action = 0xdeadbee;
9812     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9813     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9814     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9815     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9816
9817     state = 0xdeadbee;
9818     action = 0xdeadbee;
9819     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9820     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9821     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9822     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9823
9824     state = 0xdeadbee;
9825     action = 0xdeadbee;
9826     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9827     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9828     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9829     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9830
9831     state = 0xdeadbee;
9832     action = 0xdeadbee;
9833     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9834     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9835     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9836     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9837
9838     state = 0xdeadbee;
9839     action = 0xdeadbee;
9840     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9841     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9842     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9843     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9844
9845     state = 0xdeadbee;
9846     action = 0xdeadbee;
9847     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9848     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9849     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9850     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9851
9852     state = 0xdeadbee;
9853     action = 0xdeadbee;
9854     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9855     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9856     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9857     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9858
9859     state = 0xdeadbee;
9860     action = 0xdeadbee;
9861     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9862     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9863     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9864     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9865
9866     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9867     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9868
9869     r = MsiSetFeatureState(hpkg, "lyra", INSTALLSTATE_ABSENT);
9870     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9871
9872     r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
9873     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
9874
9875     state = 0xdeadbee;
9876     action = 0xdeadbee;
9877     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9878     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9879     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9880     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9881
9882     state = 0xdeadbee;
9883     action = 0xdeadbee;
9884     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9885     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9886     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9887     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9888
9889     state = 0xdeadbee;
9890     action = 0xdeadbee;
9891     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9892     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9893     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9894     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9895
9896     state = 0xdeadbee;
9897     action = 0xdeadbee;
9898     r = MsiGetFeatureState(hpkg, "lyra", &state, &action);
9899     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9900     ok( state == INSTALLSTATE_ABSENT, "Expected lyra INSTALLSTATE_ABSENT, got %d\n", state);
9901     ok( action == INSTALLSTATE_ABSENT, "Expected lyra INSTALLSTATE_ABSENT, got %d\n", action);
9902
9903     state = 0xdeadbee;
9904     action = 0xdeadbee;
9905     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9906     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9907     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9908     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9909
9910     state = 0xdeadbee;
9911     action = 0xdeadbee;
9912     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9913     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9914     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9915     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9916
9917     state = 0xdeadbee;
9918     action = 0xdeadbee;
9919     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9920     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9921     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9922     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9923
9924     state = 0xdeadbee;
9925     action = 0xdeadbee;
9926     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9927     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9928     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9929     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9930
9931     state = 0xdeadbee;
9932     action = 0xdeadbee;
9933     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9934     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9935     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9936     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9937
9938     state = 0xdeadbee;
9939     action = 0xdeadbee;
9940     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9941     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9942     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9943     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9944
9945     state = 0xdeadbee;
9946     action = 0xdeadbee;
9947     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9948     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9949     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9950     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9951
9952     state = 0xdeadbee;
9953     action = 0xdeadbee;
9954     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9955     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9956     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9957     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9958
9959     state = 0xdeadbee;
9960     action = 0xdeadbee;
9961     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9962     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9963     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9964     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9965
9966     state = 0xdeadbee;
9967     action = 0xdeadbee;
9968     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9969     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9970     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9971     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9972
9973     state = 0xdeadbee;
9974     action = 0xdeadbee;
9975     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9976     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9977     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9978     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9979     
9980     MsiCloseHandle(hpkg);
9981     DeleteFileA(msifile);
9982 }
9983
9984 static void test_installprops(void)
9985 {
9986     MSIHANDLE hpkg, hdb;
9987     CHAR path[MAX_PATH], buf[MAX_PATH];
9988     DWORD size, type;
9989     LANGID langid;
9990     HKEY hkey1, hkey2;
9991     int res;
9992     UINT r;
9993     REGSAM access = KEY_ALL_ACCESS;
9994     SYSTEM_INFO si;
9995
9996     if (is_wow64)
9997         access |= KEY_WOW64_64KEY;
9998
9999     GetCurrentDirectory(MAX_PATH, path);
10000     lstrcat(path, "\\");
10001     lstrcat(path, msifile);
10002
10003     hdb = create_package_db();
10004     ok( hdb, "failed to create database\n");
10005
10006     r = package_from_db(hdb, &hpkg);
10007     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10008     {
10009         skip("Not enough rights to perform tests\n");
10010         DeleteFile(msifile);
10011         return;
10012     }
10013     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
10014
10015     MsiCloseHandle(hdb);
10016
10017     size = MAX_PATH;
10018     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
10019     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10020     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10021
10022     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
10023     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
10024
10025     size = MAX_PATH;
10026     type = REG_SZ;
10027     *path = '\0';
10028     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
10029     {
10030         size = MAX_PATH;
10031         type = REG_SZ;
10032         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
10033     }
10034
10035     /* win9x doesn't set this */
10036     if (*path)
10037     {
10038         size = MAX_PATH;
10039         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
10040         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10041         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10042     }
10043
10044     size = MAX_PATH;
10045     type = REG_SZ;
10046     *path = '\0';
10047     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
10048     {
10049         size = MAX_PATH;
10050         type = REG_SZ;
10051         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
10052     }
10053
10054     if (*path)
10055     {
10056         size = MAX_PATH;
10057         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
10058         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10059         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10060     }
10061
10062     size = MAX_PATH;
10063     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
10064     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10065     trace("VersionDatabase = %s\n", buf);
10066
10067     size = MAX_PATH;
10068     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
10069     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10070     trace("VersionMsi = %s\n", buf);
10071
10072     size = MAX_PATH;
10073     r = MsiGetProperty(hpkg, "Date", buf, &size);
10074     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10075     trace("Date = %s\n", buf);
10076
10077     size = MAX_PATH;
10078     r = MsiGetProperty(hpkg, "Time", buf, &size);
10079     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10080     trace("Time = %s\n", buf);
10081
10082     size = MAX_PATH;
10083     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
10084     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10085     trace("PackageCode = %s\n", buf);
10086
10087     langid = GetUserDefaultLangID();
10088     sprintf(path, "%d", langid);
10089
10090     size = MAX_PATH;
10091     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
10092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
10093     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
10094
10095     res = GetSystemMetrics(SM_CXSCREEN);
10096     size = MAX_PATH;
10097     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
10098     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
10099
10100     res = GetSystemMetrics(SM_CYSCREEN);
10101     size = MAX_PATH;
10102     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
10103     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
10104
10105     if (pGetSystemInfo && pSHGetFolderPathA)
10106     {
10107         pGetSystemInfo(&si);
10108         if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
10109         {
10110             buf[0] = 0;
10111             size = MAX_PATH;
10112             r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10113             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10114             ok(buf[0], "property not set\n");
10115
10116             buf[0] = 0;
10117             size = MAX_PATH;
10118             r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10119             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10120             ok(buf[0], "property not set\n");
10121
10122             buf[0] = 0;
10123             size = MAX_PATH;
10124             r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10125             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10126             GetSystemDirectoryA(path, MAX_PATH);
10127             if (size) buf[size - 1] = 0;
10128             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10129
10130             buf[0] = 0;
10131             size = MAX_PATH;
10132             r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10133             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10134             pGetSystemWow64DirectoryA(path, MAX_PATH);
10135             if (size) buf[size - 1] = 0;
10136             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10137
10138             buf[0] = 0;
10139             size = MAX_PATH;
10140             r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
10141             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10142             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
10143             if (size) buf[size - 1] = 0;
10144             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10145
10146             buf[0] = 0;
10147             size = MAX_PATH;
10148             r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10149             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10150             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
10151             if (size) buf[size - 1] = 0;
10152             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10153
10154             buf[0] = 0;
10155             size = MAX_PATH;
10156             r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
10157             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10158             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
10159             if (size) buf[size - 1] = 0;
10160             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10161
10162             buf[0] = 0;
10163             size = MAX_PATH;
10164             r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10165             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10166             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
10167             if (size) buf[size - 1] = 0;
10168             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10169
10170             buf[0] = 0;
10171             size = MAX_PATH;
10172             r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10173             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10174             ok(buf[0], "property not set\n");
10175         }
10176         else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
10177         {
10178             if (!is_wow64)
10179             {
10180                 buf[0] = 0;
10181                 size = MAX_PATH;
10182                 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10183                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10184                 ok(!buf[0], "property set\n");
10185
10186                 buf[0] = 0;
10187                 size = MAX_PATH;
10188                 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10189                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10190                 ok(!buf[0], "property set\n");
10191
10192                 buf[0] = 0;
10193                 size = MAX_PATH;
10194                 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10195                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10196                 ok(!buf[0], "property set\n");
10197
10198                 buf[0] = 0;
10199                 size = MAX_PATH;
10200                 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10201                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10202                 GetSystemDirectoryA(path, MAX_PATH);
10203                 if (size) buf[size - 1] = 0;
10204                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10205
10206                 buf[0] = 0;
10207                 size = MAX_PATH;
10208                 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
10209                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10210                 ok(!buf[0], "property set\n");
10211
10212                 buf[0] = 0;
10213                 size = MAX_PATH;
10214                 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10215                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10216                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
10217                 if (size) buf[size - 1] = 0;
10218                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10219
10220                 buf[0] = 0;
10221                 size = MAX_PATH;
10222                 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
10223                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10224                 ok(!buf[0], "property set\n");
10225
10226                 buf[0] = 0;
10227                 size = MAX_PATH;
10228                 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10229                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10230                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
10231                 if (size) buf[size - 1] = 0;
10232                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10233
10234                 buf[0] = 0;
10235                 size = MAX_PATH;
10236                 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10237                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10238                 ok(!buf[0], "property set\n");
10239             }
10240             else
10241             {
10242                 buf[0] = 0;
10243                 size = MAX_PATH;
10244                 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10245                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10246                 ok(buf[0], "property not set\n");
10247
10248                 buf[0] = 0;
10249                 size = MAX_PATH;
10250                 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10251                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10252                 ok(buf[0], "property not set\n");
10253
10254                 buf[0] = 0;
10255                 size = MAX_PATH;
10256                 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10257                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10258                 GetSystemDirectoryA(path, MAX_PATH);
10259                 if (size) buf[size - 1] = 0;
10260                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10261
10262                 buf[0] = 0;
10263                 size = MAX_PATH;
10264                 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10265                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10266                 pGetSystemWow64DirectoryA(path, MAX_PATH);
10267                 if (size) buf[size - 1] = 0;
10268                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10269
10270                 buf[0] = 0;
10271                 size = MAX_PATH;
10272                 r = MsiGetProperty(hpkg, "ProgramFilesFolder64", buf, &size);
10273                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10274                 ok(!buf[0], "property set\n");
10275
10276                 buf[0] = 0;
10277                 size = MAX_PATH;
10278                 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10279                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10280                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
10281                 if (size) buf[size - 1] = 0;
10282                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10283
10284                 buf[0] = 0;
10285                 size = MAX_PATH;
10286                 r = MsiGetProperty(hpkg, "CommonFilesFolder64", buf, &size);
10287                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10288                 ok(!buf[0], "property set\n");
10289
10290                 buf[0] = 0;
10291                 size = MAX_PATH;
10292                 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10293                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10294                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
10295                 if (size) buf[size - 1] = 0;
10296                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10297
10298                 buf[0] = 0;
10299                 size = MAX_PATH;
10300                 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10301                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10302                 ok(buf[0], "property not set\n");
10303             }
10304         }
10305     }
10306
10307     CloseHandle(hkey1);
10308     CloseHandle(hkey2);
10309     MsiCloseHandle(hpkg);
10310     DeleteFile(msifile);
10311 }
10312
10313 static void test_launchconditions(void)
10314 {
10315     MSIHANDLE hpkg;
10316     MSIHANDLE hdb;
10317     UINT r;
10318
10319     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10320
10321     hdb = create_package_db();
10322     ok( hdb, "failed to create package database\n" );
10323
10324     r = create_launchcondition_table( hdb );
10325     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
10326
10327     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
10328     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
10329
10330     /* invalid condition */
10331     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
10332     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
10333
10334     r = package_from_db( hdb, &hpkg );
10335     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10336     {
10337         skip("Not enough rights to perform tests\n");
10338         DeleteFile(msifile);
10339         return;
10340     }
10341     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
10342
10343     MsiCloseHandle( hdb );
10344
10345     r = MsiSetProperty( hpkg, "X", "1" );
10346     ok( r == ERROR_SUCCESS, "failed to set property\n" );
10347
10348     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10349
10350     /* invalid conditions are ignored */
10351     r = MsiDoAction( hpkg, "LaunchConditions" );
10352     ok( r == ERROR_SUCCESS, "cost init failed\n" );
10353
10354     /* verify LaunchConditions still does some verification */
10355     r = MsiSetProperty( hpkg, "X", "2" );
10356     ok( r == ERROR_SUCCESS, "failed to set property\n" );
10357
10358     r = MsiDoAction( hpkg, "LaunchConditions" );
10359     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
10360
10361     MsiCloseHandle( hpkg );
10362     DeleteFile( msifile );
10363 }
10364
10365 static void test_ccpsearch(void)
10366 {
10367     MSIHANDLE hdb, hpkg;
10368     CHAR prop[MAX_PATH];
10369     DWORD size = MAX_PATH;
10370     UINT r;
10371
10372     hdb = create_package_db();
10373     ok(hdb, "failed to create package database\n");
10374
10375     r = create_ccpsearch_table(hdb);
10376     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10377
10378     r = add_ccpsearch_entry(hdb, "'CCP_random'");
10379     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10380
10381     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
10382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10383
10384     r = create_reglocator_table(hdb);
10385     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10386
10387     r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
10388     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10389
10390     r = create_drlocator_table(hdb);
10391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10392
10393     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
10394     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10395
10396     r = create_signature_table(hdb);
10397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10398
10399     r = package_from_db(hdb, &hpkg);
10400     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10401     {
10402         skip("Not enough rights to perform tests\n");
10403         DeleteFile(msifile);
10404         return;
10405     }
10406     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10407
10408     MsiCloseHandle(hdb);
10409
10410     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10411
10412     r = MsiDoAction(hpkg, "CCPSearch");
10413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10414
10415     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
10416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10417     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
10418
10419     MsiCloseHandle(hpkg);
10420     DeleteFileA(msifile);
10421 }
10422
10423 static void test_complocator(void)
10424 {
10425     MSIHANDLE hdb, hpkg;
10426     UINT r;
10427     CHAR prop[MAX_PATH];
10428     CHAR expected[MAX_PATH];
10429     DWORD size = MAX_PATH;
10430
10431     hdb = create_package_db();
10432     ok(hdb, "failed to create package database\n");
10433
10434     r = create_appsearch_table(hdb);
10435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10436
10437     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
10438     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10439
10440     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
10441     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10442
10443     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
10444     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10445
10446     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
10447     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10448
10449     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
10450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10451
10452     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
10453     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10454
10455     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
10456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10457
10458     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
10459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10460
10461     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
10462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10463
10464     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
10465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10466
10467     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
10468     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10469
10470     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
10471     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10472
10473     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
10474     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10475
10476     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
10477     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10478
10479     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
10480     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10481
10482     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
10483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10484
10485     r = create_complocator_table(hdb);
10486     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10487
10488     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
10489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10490
10491     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
10492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10493
10494     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
10495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10496
10497     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
10498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10499
10500     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
10501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10502
10503     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
10504     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10505
10506     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
10507     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10508
10509     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
10510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10511
10512     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
10513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10514
10515     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
10516     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10517
10518     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
10519     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10520
10521     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
10522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10523
10524     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
10525     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10526
10527     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
10528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10529
10530     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
10531     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10532
10533     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
10534     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10535
10536     r = create_signature_table(hdb);
10537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10538
10539     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
10540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10541
10542     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
10543     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10544
10545     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
10546     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10547
10548     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
10549     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10550
10551     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
10552     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10553
10554     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
10555     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10556
10557     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
10558     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10559
10560     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
10561     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10562
10563     r = package_from_db(hdb, &hpkg);
10564     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10565     {
10566         skip("Not enough rights to perform tests\n");
10567         DeleteFile(msifile);
10568         return;
10569     }
10570     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10571
10572     MsiCloseHandle(hdb);
10573
10574     create_test_file("abelisaurus");
10575     create_test_file("bactrosaurus");
10576     create_test_file("camelotia");
10577     create_test_file("diclonius");
10578     create_test_file("echinodon");
10579     create_test_file("falcarius");
10580     create_test_file("gallimimus");
10581     create_test_file("hagryphus");
10582     CreateDirectoryA("iguanodon", NULL);
10583     CreateDirectoryA("jobaria", NULL);
10584     CreateDirectoryA("kakuru", NULL);
10585     CreateDirectoryA("labocania", NULL);
10586     CreateDirectoryA("megaraptor", NULL);
10587     CreateDirectoryA("neosodon", NULL);
10588     CreateDirectoryA("olorotitan", NULL);
10589     CreateDirectoryA("pantydraco", NULL);
10590
10591     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
10592                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
10593     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
10594                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
10595     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
10596                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
10597     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
10598                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
10599     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
10600                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
10601     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
10602                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
10603     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
10604                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
10605     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
10606                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
10607
10608     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10609
10610     r = MsiDoAction(hpkg, "AppSearch");
10611     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10612
10613     size = MAX_PATH;
10614     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
10615     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10616
10617     lstrcpyA(expected, CURR_DIR);
10618     lstrcatA(expected, "\\abelisaurus");
10619     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10620        "Expected %s or empty string, got %s\n", expected, prop);
10621
10622     size = MAX_PATH;
10623     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
10624     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10625     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10626
10627     size = MAX_PATH;
10628     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
10629     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10630     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10631
10632     size = MAX_PATH;
10633     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
10634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10635     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10636
10637     size = MAX_PATH;
10638     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
10639     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10640
10641     lstrcpyA(expected, CURR_DIR);
10642     lstrcatA(expected, "\\");
10643     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10644        "Expected %s or empty string, got %s\n", expected, prop);
10645
10646     size = MAX_PATH;
10647     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
10648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10649     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10650
10651     size = MAX_PATH;
10652     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
10653     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10654     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10655
10656     size = MAX_PATH;
10657     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
10658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10659     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10660
10661     size = MAX_PATH;
10662     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
10663     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10664     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10665
10666     size = MAX_PATH;
10667     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
10668     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10669     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10670
10671     size = MAX_PATH;
10672     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
10673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10674     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10675
10676     size = MAX_PATH;
10677     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
10678     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10679     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10680
10681     size = MAX_PATH;
10682     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
10683     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10684
10685     lstrcpyA(expected, CURR_DIR);
10686     lstrcatA(expected, "\\");
10687     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10688        "Expected %s or empty string, got %s\n", expected, prop);
10689
10690     size = MAX_PATH;
10691     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
10692     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10693
10694     lstrcpyA(expected, CURR_DIR);
10695     lstrcatA(expected, "\\neosodon\\");
10696     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10697        "Expected %s or empty string, got %s\n", expected, prop);
10698
10699     size = MAX_PATH;
10700     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
10701     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10702     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10703
10704     size = MAX_PATH;
10705     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
10706     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10707     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10708
10709     MsiCloseHandle(hpkg);
10710     DeleteFileA("abelisaurus");
10711     DeleteFileA("bactrosaurus");
10712     DeleteFileA("camelotia");
10713     DeleteFileA("diclonius");
10714     DeleteFileA("echinodon");
10715     DeleteFileA("falcarius");
10716     DeleteFileA("gallimimus");
10717     DeleteFileA("hagryphus");
10718     RemoveDirectoryA("iguanodon");
10719     RemoveDirectoryA("jobaria");
10720     RemoveDirectoryA("kakuru");
10721     RemoveDirectoryA("labocania");
10722     RemoveDirectoryA("megaraptor");
10723     RemoveDirectoryA("neosodon");
10724     RemoveDirectoryA("olorotitan");
10725     RemoveDirectoryA("pantydraco");
10726     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
10727                           MSIINSTALLCONTEXT_MACHINE, NULL);
10728     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
10729                           MSIINSTALLCONTEXT_MACHINE, NULL);
10730     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
10731                           MSIINSTALLCONTEXT_MACHINE, NULL);
10732     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
10733                           MSIINSTALLCONTEXT_MACHINE, NULL);
10734     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
10735                           MSIINSTALLCONTEXT_MACHINE, NULL);
10736     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
10737                           MSIINSTALLCONTEXT_MACHINE, NULL);
10738     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
10739                           MSIINSTALLCONTEXT_MACHINE, NULL);
10740     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
10741                           MSIINSTALLCONTEXT_MACHINE, NULL);
10742     DeleteFileA(msifile);
10743 }
10744
10745 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
10746 {
10747     MSIHANDLE summary;
10748     UINT r;
10749
10750     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
10751     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10752
10753     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
10754     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10755
10756     r = MsiSummaryInfoPersist(summary);
10757     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10758
10759     MsiCloseHandle(summary);
10760 }
10761
10762 static void test_MsiGetSourcePath(void)
10763 {
10764     MSIHANDLE hdb, hpkg;
10765     CHAR path[MAX_PATH];
10766     CHAR cwd[MAX_PATH];
10767     CHAR subsrc[MAX_PATH];
10768     CHAR sub2[MAX_PATH];
10769     DWORD size;
10770     UINT r;
10771
10772     lstrcpyA(cwd, CURR_DIR);
10773     lstrcatA(cwd, "\\");
10774
10775     lstrcpyA(subsrc, cwd);
10776     lstrcatA(subsrc, "subsource");
10777     lstrcatA(subsrc, "\\");
10778
10779     lstrcpyA(sub2, subsrc);
10780     lstrcatA(sub2, "sub2");
10781     lstrcatA(sub2, "\\");
10782
10783     /* uncompressed source */
10784
10785     hdb = create_package_db();
10786     ok( hdb, "failed to create database\n");
10787
10788     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10789
10790     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10791     ok(r == S_OK, "failed\n");
10792
10793     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
10794     ok(r == S_OK, "failed\n");
10795
10796     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
10797     ok(r == S_OK, "failed\n");
10798
10799     r = MsiDatabaseCommit(hdb);
10800     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
10801
10802     r = package_from_db(hdb, &hpkg);
10803     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10804     {
10805         skip("Not enough rights to perform tests\n");
10806         DeleteFile(msifile);
10807         return;
10808     }
10809     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10810
10811     MsiCloseHandle(hdb);
10812
10813     /* invalid database handle */
10814     size = MAX_PATH;
10815     lstrcpyA(path, "kiwi");
10816     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
10817     ok(r == ERROR_INVALID_HANDLE,
10818        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
10819     ok(!lstrcmpA(path, "kiwi"),
10820        "Expected path to be unchanged, got \"%s\"\n", path);
10821     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10822
10823     /* NULL szFolder */
10824     size = MAX_PATH;
10825     lstrcpyA(path, "kiwi");
10826     r = MsiGetSourcePath(hpkg, NULL, path, &size);
10827     ok(r == ERROR_INVALID_PARAMETER,
10828        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10829     ok(!lstrcmpA(path, "kiwi"),
10830        "Expected path to be unchanged, got \"%s\"\n", path);
10831     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10832
10833     /* empty szFolder */
10834     size = MAX_PATH;
10835     lstrcpyA(path, "kiwi");
10836     r = MsiGetSourcePath(hpkg, "", path, &size);
10837     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10838     ok(!lstrcmpA(path, "kiwi"),
10839        "Expected path to be unchanged, got \"%s\"\n", path);
10840     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10841
10842     /* try TARGETDIR */
10843     size = MAX_PATH;
10844     lstrcpyA(path, "kiwi");
10845     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10846     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10847     ok(!lstrcmpA(path, "kiwi"),
10848        "Expected path to be unchanged, got \"%s\"\n", path);
10849     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10850
10851     size = MAX_PATH;
10852     lstrcpyA(path, "kiwi");
10853     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10854     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10855     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10856     ok(size == 0, "Expected 0, got %d\n", size);
10857
10858     size = MAX_PATH;
10859     lstrcpyA(path, "kiwi");
10860     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10862     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10863     ok(size == 0, "Expected 0, got %d\n", size);
10864
10865     /* try SourceDir */
10866     size = MAX_PATH;
10867     lstrcpyA(path, "kiwi");
10868     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10869     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10870     ok(!lstrcmpA(path, "kiwi"),
10871        "Expected path to be unchanged, got \"%s\"\n", path);
10872     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10873
10874     /* try SOURCEDIR */
10875     size = MAX_PATH;
10876     lstrcpyA(path, "kiwi");
10877     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10878     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10879     ok(!lstrcmpA(path, "kiwi"),
10880        "Expected path to be unchanged, got \"%s\"\n", path);
10881     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10882
10883     /* source path does not exist, but the property exists */
10884     size = MAX_PATH;
10885     lstrcpyA(path, "kiwi");
10886     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10887     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10888     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10889     ok(size == 0, "Expected 0, got %d\n", size);
10890
10891     size = MAX_PATH;
10892     lstrcpyA(path, "kiwi");
10893     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10895     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10896     ok(size == 0, "Expected 0, got %d\n", size);
10897
10898     /* try SubDir */
10899     size = MAX_PATH;
10900     lstrcpyA(path, "kiwi");
10901     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10902     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10903     ok(!lstrcmpA(path, "kiwi"),
10904        "Expected path to be unchanged, got \"%s\"\n", path);
10905     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10906
10907     /* try SubDir2 */
10908     size = MAX_PATH;
10909     lstrcpyA(path, "kiwi");
10910     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10911     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10912     ok(!lstrcmpA(path, "kiwi"),
10913        "Expected path to be unchanged, got \"%s\"\n", path);
10914     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10915
10916     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10917
10918     r = MsiDoAction(hpkg, "CostInitialize");
10919     ok(r == ERROR_SUCCESS, "cost init failed\n");
10920
10921     /* try TARGETDIR after CostInitialize */
10922     size = MAX_PATH;
10923     lstrcpyA(path, "kiwi");
10924     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10925     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10926     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10927     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10928
10929     /* try SourceDir after CostInitialize */
10930     size = MAX_PATH;
10931     lstrcpyA(path, "kiwi");
10932     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10933     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10934     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10935     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10936
10937     /* try SOURCEDIR after CostInitialize */
10938     size = MAX_PATH;
10939     lstrcpyA(path, "kiwi");
10940     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10941     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10942     ok(!lstrcmpA(path, "kiwi"),
10943        "Expected path to be unchanged, got \"%s\"\n", path);
10944     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10945
10946     /* source path does not exist, but the property exists */
10947     size = MAX_PATH;
10948     lstrcpyA(path, "kiwi");
10949     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10950     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10951     todo_wine
10952     {
10953         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10954         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10955     }
10956
10957     /* try SubDir after CostInitialize */
10958     size = MAX_PATH;
10959     lstrcpyA(path, "kiwi");
10960     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10961     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10962     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10963     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10964
10965     /* try SubDir2 after CostInitialize */
10966     size = MAX_PATH;
10967     lstrcpyA(path, "kiwi");
10968     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10969     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10970     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10971     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10972
10973     r = MsiDoAction(hpkg, "ResolveSource");
10974     ok(r == ERROR_SUCCESS, "file cost failed\n");
10975
10976     /* try TARGETDIR after ResolveSource */
10977     size = MAX_PATH;
10978     lstrcpyA(path, "kiwi");
10979     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10980     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10981     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10982     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10983
10984     /* try SourceDir after ResolveSource */
10985     size = MAX_PATH;
10986     lstrcpyA(path, "kiwi");
10987     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10989     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10990     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10991
10992     /* try SOURCEDIR after ResolveSource */
10993     size = MAX_PATH;
10994     lstrcpyA(path, "kiwi");
10995     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10996     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10997     ok(!lstrcmpA(path, "kiwi"),
10998        "Expected path to be unchanged, got \"%s\"\n", path);
10999     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11000
11001     /* source path does not exist, but the property exists */
11002     size = MAX_PATH;
11003     lstrcpyA(path, "kiwi");
11004     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11005     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11006     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11007     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11008
11009     /* try SubDir after ResolveSource */
11010     size = MAX_PATH;
11011     lstrcpyA(path, "kiwi");
11012     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11013     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11014     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11015     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11016
11017     /* try SubDir2 after ResolveSource */
11018     size = MAX_PATH;
11019     lstrcpyA(path, "kiwi");
11020     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11021     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11022     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11023     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11024
11025     r = MsiDoAction(hpkg, "FileCost");
11026     ok(r == ERROR_SUCCESS, "file cost failed\n");
11027
11028     /* try TARGETDIR after FileCost */
11029     size = MAX_PATH;
11030     lstrcpyA(path, "kiwi");
11031     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11032     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11033     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11034     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11035
11036     /* try SourceDir after FileCost */
11037     size = MAX_PATH;
11038     lstrcpyA(path, "kiwi");
11039     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11040     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11041     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11042     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11043
11044     /* try SOURCEDIR after FileCost */
11045     size = MAX_PATH;
11046     lstrcpyA(path, "kiwi");
11047     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11048     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11049     ok(!lstrcmpA(path, "kiwi"),
11050        "Expected path to be unchanged, got \"%s\"\n", path);
11051     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11052
11053     /* source path does not exist, but the property exists */
11054     size = MAX_PATH;
11055     lstrcpyA(path, "kiwi");
11056     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11057     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11058     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11059     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11060
11061     /* try SubDir after FileCost */
11062     size = MAX_PATH;
11063     lstrcpyA(path, "kiwi");
11064     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11066     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11067     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11068
11069     /* try SubDir2 after FileCost */
11070     size = MAX_PATH;
11071     lstrcpyA(path, "kiwi");
11072     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11073     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11074     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11075     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11076
11077     r = MsiDoAction(hpkg, "CostFinalize");
11078     ok(r == ERROR_SUCCESS, "file cost failed\n");
11079
11080     /* try TARGETDIR after CostFinalize */
11081     size = MAX_PATH;
11082     lstrcpyA(path, "kiwi");
11083     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11085     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11086     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11087
11088     /* try SourceDir after CostFinalize */
11089     size = MAX_PATH;
11090     lstrcpyA(path, "kiwi");
11091     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11092     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11093     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11094     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11095
11096     /* try SOURCEDIR after CostFinalize */
11097     size = MAX_PATH;
11098     lstrcpyA(path, "kiwi");
11099     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11100     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11101     ok(!lstrcmpA(path, "kiwi"),
11102        "Expected path to be unchanged, got \"%s\"\n", path);
11103     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11104
11105     /* source path does not exist, but the property exists */
11106     size = MAX_PATH;
11107     lstrcpyA(path, "kiwi");
11108     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11109     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11110     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11111     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11112
11113     /* try SubDir after CostFinalize */
11114     size = MAX_PATH;
11115     lstrcpyA(path, "kiwi");
11116     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11117     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11118     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11119     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11120
11121     /* try SubDir2 after CostFinalize */
11122     size = MAX_PATH;
11123     lstrcpyA(path, "kiwi");
11124     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11126     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11127     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11128
11129     /* nonexistent directory */
11130     size = MAX_PATH;
11131     lstrcpyA(path, "kiwi");
11132     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
11133     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11134     ok(!lstrcmpA(path, "kiwi"),
11135        "Expected path to be unchanged, got \"%s\"\n", path);
11136     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11137
11138     /* NULL szPathBuf */
11139     size = MAX_PATH;
11140     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
11141     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11142     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11143
11144     /* NULL pcchPathBuf */
11145     lstrcpyA(path, "kiwi");
11146     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
11147     ok(r == ERROR_INVALID_PARAMETER,
11148        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11149     ok(!lstrcmpA(path, "kiwi"),
11150        "Expected path to be unchanged, got \"%s\"\n", path);
11151
11152     /* pcchPathBuf is 0 */
11153     size = 0;
11154     lstrcpyA(path, "kiwi");
11155     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11156     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11157     ok(!lstrcmpA(path, "kiwi"),
11158        "Expected path to be unchanged, got \"%s\"\n", path);
11159     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11160
11161     /* pcchPathBuf does not have room for NULL terminator */
11162     size = lstrlenA(cwd);
11163     lstrcpyA(path, "kiwi");
11164     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11165     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11166     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
11167        "Expected path with no backslash, got \"%s\"\n", path);
11168     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11169
11170     /* pcchPathBuf has room for NULL terminator */
11171     size = lstrlenA(cwd) + 1;
11172     lstrcpyA(path, "kiwi");
11173     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11174     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11175     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11176     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11177
11178     /* remove property */
11179     r = MsiSetProperty(hpkg, "SourceDir", NULL);
11180     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11181
11182     /* try SourceDir again */
11183     size = MAX_PATH;
11184     lstrcpyA(path, "kiwi");
11185     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11186     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11187     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11188     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11189
11190     /* set property to a valid directory */
11191     r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
11192     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11193
11194     /* try SOURCEDIR again */
11195     size = MAX_PATH;
11196     lstrcpyA(path, "kiwi");
11197     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11198     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11199     ok(!lstrcmpA(path, "kiwi"),
11200        "Expected path to be unchanged, got \"%s\"\n", path);
11201     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11202
11203     MsiCloseHandle(hpkg);
11204
11205     /* compressed source */
11206
11207     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11208     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11209
11210     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
11211
11212     r = package_from_db(hdb, &hpkg);
11213     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11214
11215     /* try TARGETDIR */
11216     size = MAX_PATH;
11217     lstrcpyA(path, "kiwi");
11218     r = MsiGetSourcePath(hpkg, "TARGETDIR", 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     /* try SourceDir */
11225     size = MAX_PATH;
11226     lstrcpyA(path, "kiwi");
11227     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11228     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11229     ok(!lstrcmpA(path, "kiwi"),
11230        "Expected path to be unchanged, got \"%s\"\n", path);
11231     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11232
11233     /* try SOURCEDIR */
11234     size = MAX_PATH;
11235     lstrcpyA(path, "kiwi");
11236     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11237     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11238     ok(!lstrcmpA(path, "kiwi"),
11239        "Expected path to be unchanged, got \"%s\"\n", path);
11240     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11241
11242     /* source path nor the property exist */
11243     size = MAX_PATH;
11244     lstrcpyA(path, "kiwi");
11245     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11246     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11247     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11248     ok(size == 0, "Expected 0, got %d\n", size);
11249
11250     /* try SubDir */
11251     size = MAX_PATH;
11252     lstrcpyA(path, "kiwi");
11253     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11254     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11255     ok(!lstrcmpA(path, "kiwi"),
11256        "Expected path to be unchanged, got \"%s\"\n", path);
11257     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11258
11259     /* try SubDir2 */
11260     size = MAX_PATH;
11261     lstrcpyA(path, "kiwi");
11262     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11263     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11264     ok(!lstrcmpA(path, "kiwi"),
11265        "Expected path to be unchanged, got \"%s\"\n", path);
11266     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11267
11268     r = MsiDoAction(hpkg, "CostInitialize");
11269     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11270
11271     /* try TARGETDIR after CostInitialize */
11272     size = MAX_PATH;
11273     lstrcpyA(path, "kiwi");
11274     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11275     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11276     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11277     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11278
11279     /* try SourceDir after CostInitialize */
11280     size = MAX_PATH;
11281     lstrcpyA(path, "kiwi");
11282     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11283     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11284     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11285     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11286
11287     /* try SOURCEDIR after CostInitialize */
11288     size = MAX_PATH;
11289     lstrcpyA(path, "kiwi");
11290     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11291     todo_wine
11292     {
11293         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11294         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11295         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11296     }
11297
11298     /* source path does not exist, but the property exists */
11299     size = MAX_PATH;
11300     lstrcpyA(path, "kiwi");
11301     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11302     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11303     todo_wine
11304     {
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
11309     /* try SubDir after CostInitialize */
11310     size = MAX_PATH;
11311     lstrcpyA(path, "kiwi");
11312     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11314     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11315     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11316
11317     /* try SubDir2 after CostInitialize */
11318     size = MAX_PATH;
11319     lstrcpyA(path, "kiwi");
11320     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11321     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11322     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11323     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11324
11325     r = MsiDoAction(hpkg, "ResolveSource");
11326     ok(r == ERROR_SUCCESS, "file cost failed\n");
11327
11328     /* try TARGETDIR after ResolveSource */
11329     size = MAX_PATH;
11330     lstrcpyA(path, "kiwi");
11331     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11333     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11334     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11335
11336     /* try SourceDir after ResolveSource */
11337     size = MAX_PATH;
11338     lstrcpyA(path, "kiwi");
11339     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11340     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11341     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11342     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11343
11344     /* try SOURCEDIR after ResolveSource */
11345     size = MAX_PATH;
11346     lstrcpyA(path, "kiwi");
11347     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11348     todo_wine
11349     {
11350         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11351         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11352         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11353     }
11354
11355     /* source path and the property exist */
11356     size = MAX_PATH;
11357     lstrcpyA(path, "kiwi");
11358     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11359     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11360     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11361     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11362
11363     /* try SubDir after ResolveSource */
11364     size = MAX_PATH;
11365     lstrcpyA(path, "kiwi");
11366     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11367     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11368     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11369     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11370
11371     /* try SubDir2 after ResolveSource */
11372     size = MAX_PATH;
11373     lstrcpyA(path, "kiwi");
11374     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11375     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11376     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11377     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11378
11379     r = MsiDoAction(hpkg, "FileCost");
11380     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11381
11382     /* try TARGETDIR after CostFinalize */
11383     size = MAX_PATH;
11384     lstrcpyA(path, "kiwi");
11385     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11386     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11387     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11388     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11389
11390     /* try SourceDir after CostFinalize */
11391     size = MAX_PATH;
11392     lstrcpyA(path, "kiwi");
11393     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11394     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11395     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11396     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11397
11398     /* try SOURCEDIR after CostFinalize */
11399     size = MAX_PATH;
11400     lstrcpyA(path, "kiwi");
11401     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11402     todo_wine
11403     {
11404         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11405         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11406         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11407     }
11408
11409     /* source path and the property exist */
11410     size = MAX_PATH;
11411     lstrcpyA(path, "kiwi");
11412     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11414     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11415     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11416
11417     /* try SubDir after CostFinalize */
11418     size = MAX_PATH;
11419     lstrcpyA(path, "kiwi");
11420     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11421     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11422     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11423     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11424
11425     /* try SubDir2 after CostFinalize */
11426     size = MAX_PATH;
11427     lstrcpyA(path, "kiwi");
11428     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11429     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11430     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11431     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11432
11433     r = MsiDoAction(hpkg, "CostFinalize");
11434     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11435
11436     /* try TARGETDIR after CostFinalize */
11437     size = MAX_PATH;
11438     lstrcpyA(path, "kiwi");
11439     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11440     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11441     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11442     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11443
11444     /* try SourceDir after CostFinalize */
11445     size = MAX_PATH;
11446     lstrcpyA(path, "kiwi");
11447     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11449     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11450     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11451
11452     /* try SOURCEDIR after CostFinalize */
11453     size = MAX_PATH;
11454     lstrcpyA(path, "kiwi");
11455     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11456     todo_wine
11457     {
11458         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11459         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11460         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11461     }
11462
11463     /* source path and the property exist */
11464     size = MAX_PATH;
11465     lstrcpyA(path, "kiwi");
11466     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11467     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11468     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11469     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11470
11471     /* try SubDir after CostFinalize */
11472     size = MAX_PATH;
11473     lstrcpyA(path, "kiwi");
11474     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11476     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11477     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11478
11479     /* try SubDir2 after CostFinalize */
11480     size = MAX_PATH;
11481     lstrcpyA(path, "kiwi");
11482     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11484     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11485     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11486
11487     MsiCloseHandle(hpkg);
11488     DeleteFile(msifile);
11489 }
11490
11491 static void test_shortlongsource(void)
11492 {
11493     MSIHANDLE hdb, hpkg;
11494     CHAR path[MAX_PATH];
11495     CHAR cwd[MAX_PATH];
11496     CHAR subsrc[MAX_PATH];
11497     DWORD size;
11498     UINT r;
11499
11500     lstrcpyA(cwd, CURR_DIR);
11501     lstrcatA(cwd, "\\");
11502
11503     lstrcpyA(subsrc, cwd);
11504     lstrcatA(subsrc, "long");
11505     lstrcatA(subsrc, "\\");
11506
11507     /* long file names */
11508
11509     hdb = create_package_db();
11510     ok( hdb, "failed to create database\n");
11511
11512     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
11513
11514     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11515     ok(r == S_OK, "failed\n");
11516
11517     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
11518     ok(r == S_OK, "failed\n");
11519
11520     /* CostInitialize:short */
11521     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
11522     ok(r == S_OK, "failed\n");
11523
11524     /* CostInitialize:long */
11525     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
11526     ok(r == S_OK, "failed\n");
11527
11528     /* FileCost:short */
11529     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
11530     ok(r == S_OK, "failed\n");
11531
11532     /* FileCost:long */
11533     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
11534     ok(r == S_OK, "failed\n");
11535
11536     /* CostFinalize:short */
11537     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
11538     ok(r == S_OK, "failed\n");
11539
11540     /* CostFinalize:long */
11541     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
11542     ok(r == S_OK, "failed\n");
11543
11544     MsiDatabaseCommit(hdb);
11545
11546     r = package_from_db(hdb, &hpkg);
11547     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11548     {
11549         skip("Not enough rights to perform tests\n");
11550         DeleteFile(msifile);
11551         return;
11552     }
11553     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11554
11555     MsiCloseHandle(hdb);
11556
11557     CreateDirectoryA("one", NULL);
11558     CreateDirectoryA("four", NULL);
11559
11560     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
11561
11562     r = MsiDoAction(hpkg, "CostInitialize");
11563     ok(r == ERROR_SUCCESS, "file cost failed\n");
11564
11565     CreateDirectory("five", NULL);
11566     CreateDirectory("eight", NULL);
11567
11568     r = MsiDoAction(hpkg, "FileCost");
11569     ok(r == ERROR_SUCCESS, "file cost failed\n");
11570
11571     CreateDirectory("nine", NULL);
11572     CreateDirectory("twelve", NULL);
11573
11574     r = MsiDoAction(hpkg, "CostFinalize");
11575     ok(r == ERROR_SUCCESS, "file cost failed\n");
11576
11577     /* neither short nor long source directories exist */
11578     size = MAX_PATH;
11579     lstrcpyA(path, "kiwi");
11580     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11581     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11582     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11583     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11584
11585     CreateDirectoryA("short", NULL);
11586
11587     /* short source directory exists */
11588     size = MAX_PATH;
11589     lstrcpyA(path, "kiwi");
11590     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11591     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11592     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11593     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11594
11595     CreateDirectoryA("long", NULL);
11596
11597     /* both short and long source directories exist */
11598     size = MAX_PATH;
11599     lstrcpyA(path, "kiwi");
11600     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11601     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11602     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11603     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11604
11605     lstrcpyA(subsrc, cwd);
11606     lstrcatA(subsrc, "two");
11607     lstrcatA(subsrc, "\\");
11608
11609     /* short dir exists before CostInitialize */
11610     size = MAX_PATH;
11611     lstrcpyA(path, "kiwi");
11612     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11613     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11614     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11615     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11616
11617     lstrcpyA(subsrc, cwd);
11618     lstrcatA(subsrc, "four");
11619     lstrcatA(subsrc, "\\");
11620
11621     /* long dir exists before CostInitialize */
11622     size = MAX_PATH;
11623     lstrcpyA(path, "kiwi");
11624     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11625     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11626     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11627     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11628
11629     lstrcpyA(subsrc, cwd);
11630     lstrcatA(subsrc, "six");
11631     lstrcatA(subsrc, "\\");
11632
11633     /* short dir exists before FileCost */
11634     size = MAX_PATH;
11635     lstrcpyA(path, "kiwi");
11636     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11637     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11638     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11639     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11640
11641     lstrcpyA(subsrc, cwd);
11642     lstrcatA(subsrc, "eight");
11643     lstrcatA(subsrc, "\\");
11644
11645     /* long dir exists before FileCost */
11646     size = MAX_PATH;
11647     lstrcpyA(path, "kiwi");
11648     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11649     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11650     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11651     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11652
11653     lstrcpyA(subsrc, cwd);
11654     lstrcatA(subsrc, "ten");
11655     lstrcatA(subsrc, "\\");
11656
11657     /* short dir exists before CostFinalize */
11658     size = MAX_PATH;
11659     lstrcpyA(path, "kiwi");
11660     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11661     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11662     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11663     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11664
11665     lstrcpyA(subsrc, cwd);
11666     lstrcatA(subsrc, "twelve");
11667     lstrcatA(subsrc, "\\");
11668
11669     /* long dir exists before CostFinalize */
11670     size = MAX_PATH;
11671     lstrcpyA(path, "kiwi");
11672     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11674     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11675     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11676
11677     MsiCloseHandle(hpkg);
11678     RemoveDirectoryA("short");
11679     RemoveDirectoryA("long");
11680     RemoveDirectoryA("one");
11681     RemoveDirectoryA("four");
11682     RemoveDirectoryA("five");
11683     RemoveDirectoryA("eight");
11684     RemoveDirectoryA("nine");
11685     RemoveDirectoryA("twelve");
11686
11687     /* short file names */
11688
11689     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11690     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11691
11692     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
11693
11694     r = package_from_db(hdb, &hpkg);
11695     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11696
11697     MsiCloseHandle(hdb);
11698
11699     CreateDirectoryA("one", NULL);
11700     CreateDirectoryA("four", NULL);
11701
11702     r = MsiDoAction(hpkg, "CostInitialize");
11703     ok(r == ERROR_SUCCESS, "file cost failed\n");
11704
11705     CreateDirectory("five", NULL);
11706     CreateDirectory("eight", NULL);
11707
11708     r = MsiDoAction(hpkg, "FileCost");
11709     ok(r == ERROR_SUCCESS, "file cost failed\n");
11710
11711     CreateDirectory("nine", NULL);
11712     CreateDirectory("twelve", NULL);
11713
11714     r = MsiDoAction(hpkg, "CostFinalize");
11715     ok(r == ERROR_SUCCESS, "file cost failed\n");
11716
11717     lstrcpyA(subsrc, cwd);
11718     lstrcatA(subsrc, "short");
11719     lstrcatA(subsrc, "\\");
11720
11721     /* neither short nor long source directories exist */
11722     size = MAX_PATH;
11723     lstrcpyA(path, "kiwi");
11724     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11726     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11727     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11728
11729     CreateDirectoryA("short", NULL);
11730
11731     /* short source directory exists */
11732     size = MAX_PATH;
11733     lstrcpyA(path, "kiwi");
11734     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11735     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11736     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11737     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11738
11739     CreateDirectoryA("long", NULL);
11740
11741     /* both short and long source directories exist */
11742     size = MAX_PATH;
11743     lstrcpyA(path, "kiwi");
11744     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11746     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11747     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11748
11749     lstrcpyA(subsrc, cwd);
11750     lstrcatA(subsrc, "one");
11751     lstrcatA(subsrc, "\\");
11752
11753     /* short dir exists before CostInitialize */
11754     size = MAX_PATH;
11755     lstrcpyA(path, "kiwi");
11756     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11757     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11758     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11759     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11760
11761     lstrcpyA(subsrc, cwd);
11762     lstrcatA(subsrc, "three");
11763     lstrcatA(subsrc, "\\");
11764
11765     /* long dir exists before CostInitialize */
11766     size = MAX_PATH;
11767     lstrcpyA(path, "kiwi");
11768     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11769     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11770     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11771     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11772
11773     lstrcpyA(subsrc, cwd);
11774     lstrcatA(subsrc, "five");
11775     lstrcatA(subsrc, "\\");
11776
11777     /* short dir exists before FileCost */
11778     size = MAX_PATH;
11779     lstrcpyA(path, "kiwi");
11780     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11781     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11782     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11783     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11784
11785     lstrcpyA(subsrc, cwd);
11786     lstrcatA(subsrc, "seven");
11787     lstrcatA(subsrc, "\\");
11788
11789     /* long dir exists before FileCost */
11790     size = MAX_PATH;
11791     lstrcpyA(path, "kiwi");
11792     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11793     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11794     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11795     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11796
11797     lstrcpyA(subsrc, cwd);
11798     lstrcatA(subsrc, "nine");
11799     lstrcatA(subsrc, "\\");
11800
11801     /* short dir exists before CostFinalize */
11802     size = MAX_PATH;
11803     lstrcpyA(path, "kiwi");
11804     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11805     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11806     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11807     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11808
11809     lstrcpyA(subsrc, cwd);
11810     lstrcatA(subsrc, "eleven");
11811     lstrcatA(subsrc, "\\");
11812
11813     /* long dir exists before CostFinalize */
11814     size = MAX_PATH;
11815     lstrcpyA(path, "kiwi");
11816     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11817     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11818     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11819     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11820
11821     MsiCloseHandle(hpkg);
11822     RemoveDirectoryA("short");
11823     RemoveDirectoryA("long");
11824     RemoveDirectoryA("one");
11825     RemoveDirectoryA("four");
11826     RemoveDirectoryA("five");
11827     RemoveDirectoryA("eight");
11828     RemoveDirectoryA("nine");
11829     RemoveDirectoryA("twelve");
11830     DeleteFileA(msifile);
11831 }
11832
11833 static void test_sourcedir(void)
11834 {
11835     MSIHANDLE hdb, hpkg;
11836     CHAR package[12];
11837     CHAR path[MAX_PATH];
11838     CHAR cwd[MAX_PATH];
11839     CHAR subsrc[MAX_PATH];
11840     DWORD size;
11841     UINT r;
11842
11843     lstrcpyA(cwd, CURR_DIR);
11844     lstrcatA(cwd, "\\");
11845
11846     lstrcpyA(subsrc, cwd);
11847     lstrcatA(subsrc, "long");
11848     lstrcatA(subsrc, "\\");
11849
11850     hdb = create_package_db();
11851     ok( hdb, "failed to create database\n");
11852
11853     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11854     ok(r == S_OK, "failed\n");
11855
11856     sprintf(package, "#%u", hdb);
11857     r = MsiOpenPackage(package, &hpkg);
11858     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11859     {
11860         skip("Not enough rights to perform tests\n");
11861         goto error;
11862     }
11863     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11864
11865     /* properties only */
11866
11867     /* SourceDir prop */
11868     size = MAX_PATH;
11869     lstrcpyA(path, "kiwi");
11870     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11871     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11872     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11873     ok(size == 0, "Expected 0, got %d\n", size);
11874
11875     /* SOURCEDIR prop */
11876     size = MAX_PATH;
11877     lstrcpyA(path, "kiwi");
11878     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11879     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11880     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11881     ok(size == 0, "Expected 0, got %d\n", size);
11882
11883     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
11884
11885     r = MsiDoAction(hpkg, "CostInitialize");
11886     ok(r == ERROR_SUCCESS, "file cost failed\n");
11887
11888     /* SourceDir after CostInitialize */
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 after CostInitialize */
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     r = MsiDoAction(hpkg, "FileCost");
11905     ok(r == ERROR_SUCCESS, "file cost failed\n");
11906
11907     /* SourceDir after FileCost */
11908     size = MAX_PATH;
11909     lstrcpyA(path, "kiwi");
11910     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11911     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11912     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11913     ok(size == 0, "Expected 0, got %d\n", size);
11914
11915     /* SOURCEDIR after FileCost */
11916     size = MAX_PATH;
11917     lstrcpyA(path, "kiwi");
11918     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11919     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11920     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11921     ok(size == 0, "Expected 0, got %d\n", size);
11922
11923     r = MsiDoAction(hpkg, "CostFinalize");
11924     ok(r == ERROR_SUCCESS, "file cost failed\n");
11925
11926     /* SourceDir after CostFinalize */
11927     size = MAX_PATH;
11928     lstrcpyA(path, "kiwi");
11929     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11930     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11931     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11932     ok(size == 0, "Expected 0, got %d\n", size);
11933
11934     /* SOURCEDIR after CostFinalize */
11935     size = MAX_PATH;
11936     lstrcpyA(path, "kiwi");
11937     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11938     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11939     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11940     ok(size == 0, "Expected 0, got %d\n", size);
11941
11942     r = MsiDoAction(hpkg, "ResolveSource");
11943     ok(r == ERROR_SUCCESS, "file cost failed\n");
11944
11945     /* SourceDir after ResolveSource */
11946     size = MAX_PATH;
11947     lstrcpyA(path, "kiwi");
11948     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11949     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11950     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11951     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11952
11953     /* SOURCEDIR after ResolveSource */
11954     size = MAX_PATH;
11955     lstrcpyA(path, "kiwi");
11956     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11957     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11958     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11959     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11960
11961     /* random casing */
11962     size = MAX_PATH;
11963     lstrcpyA(path, "kiwi");
11964     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
11965     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11966     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11967     ok(size == 0, "Expected 0, got %d\n", size);
11968
11969     MsiCloseHandle(hpkg);
11970
11971     /* reset the package state */
11972     sprintf(package, "#%i", hdb);
11973     r = MsiOpenPackage(package, &hpkg);
11974     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11975
11976     /* test how MsiGetSourcePath affects the properties */
11977
11978     /* SourceDir prop */
11979     size = MAX_PATH;
11980     lstrcpyA(path, "kiwi");
11981     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11982     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11983     todo_wine
11984     {
11985         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11986         ok(size == 0, "Expected 0, got %d\n", size);
11987     }
11988
11989     size = MAX_PATH;
11990     lstrcpyA(path, "kiwi");
11991     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11992     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11993     ok(!lstrcmpA(path, "kiwi"),
11994        "Expected path to be unchanged, got \"%s\"\n", path);
11995     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11996
11997     /* SourceDir after MsiGetSourcePath */
11998     size = MAX_PATH;
11999     lstrcpyA(path, "kiwi");
12000     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12001     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12002     todo_wine
12003     {
12004         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12005         ok(size == 0, "Expected 0, got %d\n", size);
12006     }
12007
12008     /* SOURCEDIR prop */
12009     size = MAX_PATH;
12010     lstrcpyA(path, "kiwi");
12011     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12013     todo_wine
12014     {
12015         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12016         ok(size == 0, "Expected 0, got %d\n", size);
12017     }
12018
12019     size = MAX_PATH;
12020     lstrcpyA(path, "kiwi");
12021     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12022     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12023     ok(!lstrcmpA(path, "kiwi"),
12024        "Expected path to be unchanged, got \"%s\"\n", path);
12025     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12026
12027     /* SOURCEDIR prop after MsiGetSourcePath */
12028     size = MAX_PATH;
12029     lstrcpyA(path, "kiwi");
12030     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12031     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12032     todo_wine
12033     {
12034         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12035         ok(size == 0, "Expected 0, got %d\n", size);
12036     }
12037
12038     r = MsiDoAction(hpkg, "CostInitialize");
12039     ok(r == ERROR_SUCCESS, "file cost failed\n");
12040
12041     /* SourceDir after CostInitialize */
12042     size = MAX_PATH;
12043     lstrcpyA(path, "kiwi");
12044     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12045     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12046     todo_wine
12047     {
12048         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
12049         ok(size == 0, "Expected 0, got %d\n", size);
12050     }
12051
12052     size = MAX_PATH;
12053     lstrcpyA(path, "kiwi");
12054     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
12055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12056     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12057     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12058
12059     /* SourceDir after MsiGetSourcePath */
12060     size = MAX_PATH;
12061     lstrcpyA(path, "kiwi");
12062     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12063     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12064     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12065     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12066
12067     /* SOURCEDIR after CostInitialize */
12068     size = MAX_PATH;
12069     lstrcpyA(path, "kiwi");
12070     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12071     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12072     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12073     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12074
12075     /* SOURCEDIR source path still does not exist */
12076     size = MAX_PATH;
12077     lstrcpyA(path, "kiwi");
12078     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12079     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12080     ok(!lstrcmpA(path, "kiwi"),
12081        "Expected path to be unchanged, got \"%s\"\n", path);
12082     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12083
12084     r = MsiDoAction(hpkg, "FileCost");
12085     ok(r == ERROR_SUCCESS, "file cost failed\n");
12086
12087     /* SourceDir after FileCost */
12088     size = MAX_PATH;
12089     lstrcpyA(path, "kiwi");
12090     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12091     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12092     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12093     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12094
12095     /* SOURCEDIR after FileCost */
12096     size = MAX_PATH;
12097     lstrcpyA(path, "kiwi");
12098     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12100     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12101     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12102
12103     /* SOURCEDIR source path still does not exist */
12104     size = MAX_PATH;
12105     lstrcpyA(path, "kiwi");
12106     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12107     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12108     ok(!lstrcmpA(path, "kiwi"),
12109        "Expected path to be unchanged, got \"%s\"\n", path);
12110     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12111
12112     r = MsiDoAction(hpkg, "CostFinalize");
12113     ok(r == ERROR_SUCCESS, "file cost failed\n");
12114
12115     /* SourceDir after CostFinalize */
12116     size = MAX_PATH;
12117     lstrcpyA(path, "kiwi");
12118     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12120     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12121     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12122
12123     /* SOURCEDIR after CostFinalize */
12124     size = MAX_PATH;
12125     lstrcpyA(path, "kiwi");
12126     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12127     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12128     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12129     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12130
12131     /* SOURCEDIR source path still does not exist */
12132     size = MAX_PATH;
12133     lstrcpyA(path, "kiwi");
12134     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12135     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12136     ok(!lstrcmpA(path, "kiwi"),
12137        "Expected path to be unchanged, got \"%s\"\n", path);
12138     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12139
12140     r = MsiDoAction(hpkg, "ResolveSource");
12141     ok(r == ERROR_SUCCESS, "file cost failed\n");
12142
12143     /* SourceDir after ResolveSource */
12144     size = MAX_PATH;
12145     lstrcpyA(path, "kiwi");
12146     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12148     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12149     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12150
12151     /* SOURCEDIR after ResolveSource */
12152     size = MAX_PATH;
12153     lstrcpyA(path, "kiwi");
12154     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12155     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12156     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12157     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12158
12159     /* SOURCEDIR source path still does not exist */
12160     size = MAX_PATH;
12161     lstrcpyA(path, "kiwi");
12162     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12163     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12164     ok(!lstrcmpA(path, "kiwi"),
12165        "Expected path to be unchanged, got \"%s\"\n", path);
12166     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12167
12168     MsiCloseHandle(hpkg);
12169
12170 error:
12171     MsiCloseHandle(hdb);
12172     DeleteFileA(msifile);
12173 }
12174
12175 struct access_res
12176 {
12177     BOOL gothandle;
12178     DWORD lasterr;
12179     BOOL ignore;
12180 };
12181
12182 static const struct access_res create[16] =
12183 {
12184     { TRUE, ERROR_SUCCESS, TRUE },
12185     { TRUE, ERROR_SUCCESS, TRUE },
12186     { TRUE, ERROR_SUCCESS, FALSE },
12187     { TRUE, ERROR_SUCCESS, FALSE },
12188     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12189     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12190     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12191     { TRUE, ERROR_SUCCESS, FALSE },
12192     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12193     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12194     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12195     { TRUE, ERROR_SUCCESS, TRUE },
12196     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12197     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12198     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12199     { TRUE, ERROR_SUCCESS, TRUE }
12200 };
12201
12202 static const struct access_res create_commit[16] =
12203 {
12204     { TRUE, ERROR_SUCCESS, TRUE },
12205     { TRUE, ERROR_SUCCESS, TRUE },
12206     { TRUE, ERROR_SUCCESS, FALSE },
12207     { TRUE, ERROR_SUCCESS, FALSE },
12208     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12209     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12210     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12211     { TRUE, ERROR_SUCCESS, FALSE },
12212     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12213     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12214     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12215     { TRUE, ERROR_SUCCESS, TRUE },
12216     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12217     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12218     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12219     { TRUE, ERROR_SUCCESS, TRUE }
12220 };
12221
12222 static const struct access_res create_close[16] =
12223 {
12224     { TRUE, ERROR_SUCCESS, FALSE },
12225     { TRUE, ERROR_SUCCESS, FALSE },
12226     { TRUE, ERROR_SUCCESS, FALSE },
12227     { TRUE, ERROR_SUCCESS, FALSE },
12228     { TRUE, ERROR_SUCCESS, FALSE },
12229     { TRUE, ERROR_SUCCESS, FALSE },
12230     { TRUE, ERROR_SUCCESS, FALSE },
12231     { TRUE, ERROR_SUCCESS, FALSE },
12232     { TRUE, ERROR_SUCCESS, FALSE },
12233     { TRUE, ERROR_SUCCESS, FALSE },
12234     { TRUE, ERROR_SUCCESS, FALSE },
12235     { TRUE, ERROR_SUCCESS, FALSE },
12236     { TRUE, ERROR_SUCCESS, FALSE },
12237     { TRUE, ERROR_SUCCESS, FALSE },
12238     { TRUE, ERROR_SUCCESS, FALSE },
12239     { TRUE, ERROR_SUCCESS }
12240 };
12241
12242 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
12243 {
12244     DWORD access = 0, share = 0;
12245     DWORD lasterr;
12246     HANDLE hfile;
12247     int i, j, idx = 0;
12248
12249     for (i = 0; i < 4; i++)
12250     {
12251         if (i == 0) access = 0;
12252         if (i == 1) access = GENERIC_READ;
12253         if (i == 2) access = GENERIC_WRITE;
12254         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
12255
12256         for (j = 0; j < 4; j++)
12257         {
12258             if (ares[idx].ignore)
12259                 continue;
12260
12261             if (j == 0) share = 0;
12262             if (j == 1) share = FILE_SHARE_READ;
12263             if (j == 2) share = FILE_SHARE_WRITE;
12264             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
12265
12266             SetLastError(0xdeadbeef);
12267             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
12268                                 FILE_ATTRIBUTE_NORMAL, 0);
12269             lasterr = GetLastError();
12270
12271             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
12272                "(%d, handle, %d): Expected %d, got %d\n",
12273                line, idx, ares[idx].gothandle,
12274                (hfile != INVALID_HANDLE_VALUE));
12275
12276             ok(lasterr == ares[idx].lasterr ||
12277                lasterr == 0xdeadbeef, /* win9x */
12278                "(%d, lasterr, %d): Expected %d, got %d\n",
12279                line, idx, ares[idx].lasterr, lasterr);
12280
12281             CloseHandle(hfile);
12282             idx++;
12283         }
12284     }
12285 }
12286
12287 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
12288
12289 static void test_access(void)
12290 {
12291     MSIHANDLE hdb;
12292     UINT r;
12293
12294     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
12295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12296
12297     test_file_access(msifile, create);
12298
12299     r = MsiDatabaseCommit(hdb);
12300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12301
12302     test_file_access(msifile, create_commit);
12303     MsiCloseHandle(hdb);
12304
12305     test_file_access(msifile, create_close);
12306     DeleteFileA(msifile);
12307
12308     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
12309     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12310
12311     test_file_access(msifile, create);
12312
12313     r = MsiDatabaseCommit(hdb);
12314     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12315
12316     test_file_access(msifile, create_commit);
12317     MsiCloseHandle(hdb);
12318
12319     test_file_access(msifile, create_close);
12320     DeleteFileA(msifile);
12321 }
12322
12323 static void test_emptypackage(void)
12324 {
12325     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
12326     MSIHANDLE hview = 0, hrec = 0;
12327     MSICONDITION condition;
12328     CHAR buffer[MAX_PATH];
12329     DWORD size;
12330     UINT r;
12331
12332     r = MsiOpenPackageA("", &hpkg);
12333     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12334     {
12335         skip("Not enough rights to perform tests\n");
12336         return;
12337     }
12338     todo_wine
12339     {
12340         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12341     }
12342
12343     hdb = MsiGetActiveDatabase(hpkg);
12344     todo_wine
12345     {
12346         ok(hdb != 0, "Expected a valid database handle\n");
12347     }
12348
12349     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
12350     todo_wine
12351     {
12352         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12353     }
12354     r = MsiViewExecute(hview, 0);
12355     todo_wine
12356     {
12357         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12358     }
12359
12360     r = MsiViewFetch(hview, &hrec);
12361     todo_wine
12362     {
12363         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12364     }
12365
12366     buffer[0] = 0;
12367     size = MAX_PATH;
12368     r = MsiRecordGetString(hrec, 1, buffer, &size);
12369     todo_wine
12370     {
12371         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12372         ok(!lstrcmpA(buffer, "_Property"),
12373            "Expected \"_Property\", got \"%s\"\n", buffer);
12374     }
12375
12376     MsiCloseHandle(hrec);
12377
12378     r = MsiViewFetch(hview, &hrec);
12379     todo_wine
12380     {
12381         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12382     }
12383
12384     size = MAX_PATH;
12385     r = MsiRecordGetString(hrec, 1, buffer, &size);
12386     todo_wine
12387     {
12388         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12389         ok(!lstrcmpA(buffer, "#_FolderCache"),
12390            "Expected \"_Property\", got \"%s\"\n", buffer);
12391     }
12392
12393     MsiCloseHandle(hrec);
12394     MsiViewClose(hview);
12395     MsiCloseHandle(hview);
12396
12397     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
12398     todo_wine
12399     {
12400         ok(condition == MSICONDITION_FALSE,
12401            "Expected MSICONDITION_FALSE, got %d\n", condition);
12402     }
12403
12404     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
12405     todo_wine
12406     {
12407         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12408     }
12409     r = MsiViewExecute(hview, 0);
12410     todo_wine
12411     {
12412         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12413     }
12414
12415     /* _Property table is not empty */
12416     r = MsiViewFetch(hview, &hrec);
12417     todo_wine
12418     {
12419         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12420     }
12421
12422     MsiCloseHandle(hrec);
12423     MsiViewClose(hview);
12424     MsiCloseHandle(hview);
12425
12426     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
12427     todo_wine
12428     {
12429         ok(condition == MSICONDITION_FALSE,
12430            "Expected MSICONDITION_FALSE, got %d\n", condition);
12431     }
12432
12433     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
12434     todo_wine
12435     {
12436         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12437     }
12438     r = MsiViewExecute(hview, 0);
12439     todo_wine
12440     {
12441         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12442     }
12443
12444     /* #_FolderCache is not empty */
12445     r = MsiViewFetch(hview, &hrec);
12446     todo_wine
12447     {
12448         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12449     }
12450
12451     MsiCloseHandle(hrec);
12452     MsiViewClose(hview);
12453     MsiCloseHandle(hview);
12454
12455     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
12456     todo_wine
12457     {
12458         ok(r == ERROR_BAD_QUERY_SYNTAX,
12459            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12460     }
12461
12462     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
12463     todo_wine
12464     {
12465         ok(r == ERROR_BAD_QUERY_SYNTAX,
12466            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12467     }
12468
12469     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
12470     todo_wine
12471     {
12472         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
12473            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
12474     }
12475
12476     MsiCloseHandle(hsuminfo);
12477
12478     r = MsiDatabaseCommit(hdb);
12479     todo_wine
12480     {
12481         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12482     }
12483
12484     MsiCloseHandle(hdb);
12485     MsiCloseHandle(hpkg);
12486 }
12487
12488 static void test_MsiGetProductProperty(void)
12489 {
12490     MSIHANDLE hprod, hdb;
12491     CHAR val[MAX_PATH];
12492     CHAR path[MAX_PATH];
12493     CHAR query[MAX_PATH];
12494     CHAR keypath[MAX_PATH*2];
12495     CHAR prodcode[MAX_PATH];
12496     CHAR prod_squashed[MAX_PATH];
12497     HKEY prodkey, userkey, props;
12498     DWORD size;
12499     LONG res;
12500     UINT r;
12501     SC_HANDLE scm;
12502     REGSAM access = KEY_ALL_ACCESS;
12503
12504     scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
12505     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
12506     {
12507         win_skip("Different registry keys on Win9x and WinMe\n");
12508         return;
12509     }
12510     CloseServiceHandle(scm);
12511
12512     GetCurrentDirectoryA(MAX_PATH, path);
12513     lstrcatA(path, "\\");
12514
12515     create_test_guid(prodcode, prod_squashed);
12516
12517     if (is_wow64)
12518         access |= KEY_WOW64_64KEY;
12519
12520     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
12521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12522
12523     r = MsiDatabaseCommit(hdb);
12524     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12525
12526     r = set_summary_info(hdb);
12527     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12528
12529     r = run_query(hdb,
12530             "CREATE TABLE `Directory` ( "
12531             "`Directory` CHAR(255) NOT NULL, "
12532             "`Directory_Parent` CHAR(255), "
12533             "`DefaultDir` CHAR(255) NOT NULL "
12534             "PRIMARY KEY `Directory`)");
12535     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12536
12537     r = run_query(hdb,
12538             "CREATE TABLE `Property` ( "
12539             "`Property` CHAR(72) NOT NULL, "
12540             "`Value` CHAR(255) "
12541             "PRIMARY KEY `Property`)");
12542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12543
12544     sprintf(query, "INSERT INTO `Property` "
12545             "(`Property`, `Value`) "
12546             "VALUES( 'ProductCode', '%s' )", prodcode);
12547     r = run_query(hdb, query);
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     MsiCloseHandle(hdb);
12554
12555     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12556     lstrcatA(keypath, prod_squashed);
12557
12558     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12559     if (res == ERROR_ACCESS_DENIED)
12560     {
12561         skip("Not enough rights to perform tests\n");
12562         DeleteFile(msifile);
12563         return;
12564     }
12565     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12566
12567     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
12568     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
12569     lstrcatA(keypath, prod_squashed);
12570
12571     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
12572     if (res == ERROR_ACCESS_DENIED)
12573     {
12574         skip("Not enough rights to perform tests\n");
12575         RegDeleteKeyA(prodkey, "");
12576         RegCloseKey(prodkey);
12577         return;
12578     }
12579     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12580
12581     res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12582     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12583
12584     lstrcpyA(val, path);
12585     lstrcatA(val, "\\");
12586     lstrcatA(val, msifile);
12587     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
12588                          (const BYTE *)val, lstrlenA(val) + 1);
12589     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12590
12591     hprod = 0xdeadbeef;
12592     r = MsiOpenProductA(prodcode, &hprod);
12593     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12594     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
12595
12596     /* hProduct is invalid */
12597     size = MAX_PATH;
12598     lstrcpyA(val, "apple");
12599     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
12600     ok(r == ERROR_INVALID_HANDLE,
12601        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12602     ok(!lstrcmpA(val, "apple"),
12603        "Expected val to be unchanged, got \"%s\"\n", val);
12604     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12605
12606     /* szProperty is NULL */
12607     size = MAX_PATH;
12608     lstrcpyA(val, "apple");
12609     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
12610     ok(r == ERROR_INVALID_PARAMETER,
12611        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12612     ok(!lstrcmpA(val, "apple"),
12613        "Expected val to be unchanged, got \"%s\"\n", val);
12614     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12615
12616     /* szProperty is empty */
12617     size = MAX_PATH;
12618     lstrcpyA(val, "apple");
12619     r = MsiGetProductPropertyA(hprod, "", val, &size);
12620     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12621     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12622     ok(size == 0, "Expected 0, got %d\n", size);
12623
12624     /* get the property */
12625     size = MAX_PATH;
12626     lstrcpyA(val, "apple");
12627     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12628     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12629     ok(!lstrcmpA(val, prodcode),
12630        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12631     ok(size == lstrlenA(prodcode),
12632        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12633
12634     /* lpValueBuf is NULL */
12635     size = MAX_PATH;
12636     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
12637     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12638     ok(size == lstrlenA(prodcode),
12639        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12640
12641     /* pcchValueBuf is NULL */
12642     lstrcpyA(val, "apple");
12643     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
12644     ok(r == ERROR_INVALID_PARAMETER,
12645        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12646     ok(!lstrcmpA(val, "apple"),
12647        "Expected val to be unchanged, got \"%s\"\n", val);
12648     ok(size == lstrlenA(prodcode),
12649        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12650
12651     /* pcchValueBuf is too small */
12652     size = 4;
12653     lstrcpyA(val, "apple");
12654     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12655     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12656     ok(!strncmp(val, prodcode, 3),
12657        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
12658     ok(size == lstrlenA(prodcode),
12659        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12660
12661     /* pcchValueBuf does not leave room for NULL terminator */
12662     size = lstrlenA(prodcode);
12663     lstrcpyA(val, "apple");
12664     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12665     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12666     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
12667        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
12668     ok(size == lstrlenA(prodcode),
12669        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12670
12671     /* pcchValueBuf has enough room for NULL terminator */
12672     size = lstrlenA(prodcode) + 1;
12673     lstrcpyA(val, "apple");
12674     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12675     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12676     ok(!lstrcmpA(val, prodcode),
12677        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12678     ok(size == lstrlenA(prodcode),
12679        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12680
12681     /* nonexistent property */
12682     size = MAX_PATH;
12683     lstrcpyA(val, "apple");
12684     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
12685     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12686     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12687     ok(size == 0, "Expected 0, got %d\n", size);
12688
12689     r = MsiSetPropertyA(hprod, "NewProperty", "value");
12690     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12691
12692     /* non-product property set */
12693     size = MAX_PATH;
12694     lstrcpyA(val, "apple");
12695     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
12696     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12697     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12698     ok(size == 0, "Expected 0, got %d\n", size);
12699
12700     r = MsiSetPropertyA(hprod, "ProductCode", "value");
12701     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12702
12703     /* non-product property that is also a product property set */
12704     size = MAX_PATH;
12705     lstrcpyA(val, "apple");
12706     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12707     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12708     ok(!lstrcmpA(val, prodcode),
12709        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12710     ok(size == lstrlenA(prodcode),
12711        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12712
12713     MsiCloseHandle(hprod);
12714
12715     RegDeleteValueA(props, "LocalPackage");
12716     delete_key(props, "", access);
12717     RegCloseKey(props);
12718     delete_key(userkey, "", access);
12719     RegCloseKey(userkey);
12720     delete_key(prodkey, "", access);
12721     RegCloseKey(prodkey);
12722     DeleteFileA(msifile);
12723 }
12724
12725 static void test_MsiSetProperty(void)
12726 {
12727     MSIHANDLE hpkg, hdb, hrec;
12728     CHAR buf[MAX_PATH];
12729     LPCSTR query;
12730     DWORD size;
12731     UINT r;
12732
12733     r = package_from_db(create_package_db(), &hpkg);
12734     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12735     {
12736         skip("Not enough rights to perform tests\n");
12737         DeleteFile(msifile);
12738         return;
12739     }
12740     ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
12741
12742     /* invalid hInstall */
12743     r = MsiSetPropertyA(0, "Prop", "Val");
12744     ok(r == ERROR_INVALID_HANDLE,
12745        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12746
12747     /* invalid hInstall */
12748     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
12749     ok(r == ERROR_INVALID_HANDLE,
12750        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12751
12752     /* szName is NULL */
12753     r = MsiSetPropertyA(hpkg, NULL, "Val");
12754     ok(r == ERROR_INVALID_PARAMETER,
12755        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12756
12757     /* both szName and szValue are NULL */
12758     r = MsiSetPropertyA(hpkg, NULL, NULL);
12759     ok(r == ERROR_INVALID_PARAMETER,
12760        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12761
12762     /* szName is empty */
12763     r = MsiSetPropertyA(hpkg, "", "Val");
12764     ok(r == ERROR_FUNCTION_FAILED,
12765        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
12766
12767     /* szName is empty and szValue is NULL */
12768     r = MsiSetPropertyA(hpkg, "", NULL);
12769     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12770
12771     /* set a property */
12772     r = MsiSetPropertyA(hpkg, "Prop", "Val");
12773     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12774
12775     /* get the property */
12776     size = MAX_PATH;
12777     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12779     ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
12780     ok(size == 3, "Expected 3, got %d\n", size);
12781
12782     /* update the property */
12783     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
12784     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12785
12786     /* get the property */
12787     size = MAX_PATH;
12788     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12790     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
12791     ok(size == 4, "Expected 4, got %d\n", size);
12792
12793     hdb = MsiGetActiveDatabase(hpkg);
12794     ok(hdb != 0, "Expected a valid database handle\n");
12795
12796     /* set prop is not in the _Property table */
12797     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
12798     r = do_query(hdb, query, &hrec);
12799     ok(r == ERROR_BAD_QUERY_SYNTAX,
12800        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12801
12802     /* set prop is not in the Property table */
12803     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
12804     r = do_query(hdb, query, &hrec);
12805     ok(r == ERROR_BAD_QUERY_SYNTAX,
12806        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12807
12808     MsiCloseHandle(hdb);
12809
12810     /* szValue is an empty string */
12811     r = MsiSetPropertyA(hpkg, "Prop", "");
12812     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12813
12814     /* try to get the property */
12815     size = MAX_PATH;
12816     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12817     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12818     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12819     ok(size == 0, "Expected 0, got %d\n", size);
12820
12821     /* reset the property */
12822     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
12823     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12824
12825     /* delete the property */
12826     r = MsiSetPropertyA(hpkg, "Prop", NULL);
12827     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12828
12829     /* try to get the property */
12830     size = MAX_PATH;
12831     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12832     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12833     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12834     ok(size == 0, "Expected 0, got %d\n", size);
12835
12836     MsiCloseHandle(hpkg);
12837     DeleteFileA(msifile);
12838 }
12839
12840 static void test_MsiApplyMultiplePatches(void)
12841 {
12842     UINT r, type = GetDriveType(NULL);
12843
12844     if (!pMsiApplyMultiplePatchesA) {
12845         win_skip("MsiApplyMultiplePatchesA not found\n");
12846         return;
12847     }
12848
12849     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
12850     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12851
12852     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
12853     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12854
12855     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
12856     if (type == DRIVE_FIXED)
12857         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12858     else
12859         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12860
12861     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
12862     if (type == DRIVE_FIXED)
12863         todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
12864     else
12865         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12866
12867     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
12868     if (type == DRIVE_FIXED)
12869         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12870     else
12871         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12872
12873     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
12874     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12875
12876     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
12877     if (type == DRIVE_FIXED)
12878         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12879     else
12880         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12881
12882     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
12883     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12884
12885     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
12886     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12887 }
12888
12889 static void test_MsiApplyPatch(void)
12890 {
12891     UINT r;
12892
12893     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
12894     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12895
12896     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
12897     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12898 }
12899
12900 START_TEST(package)
12901 {
12902     STATEMGRSTATUS status;
12903     BOOL ret = FALSE;
12904
12905     init_functionpointers();
12906
12907     if (pIsWow64Process)
12908         pIsWow64Process(GetCurrentProcess(), &is_wow64);
12909
12910     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
12911
12912     /* Create a restore point ourselves so we circumvent the multitude of restore points
12913      * that would have been created by all the installation and removal tests.
12914      *
12915      * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
12916      * creation of restore points.
12917      */
12918     if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
12919     {
12920         memset(&status, 0, sizeof(status));
12921         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
12922     }
12923
12924     test_createpackage();
12925     test_doaction();
12926     test_gettargetpath_bad();
12927     test_settargetpath();
12928     test_props();
12929     test_property_table();
12930     test_condition();
12931     test_msipackage();
12932     test_formatrecord2();
12933     test_states();
12934     test_getproperty();
12935     test_removefiles();
12936     test_appsearch();
12937     test_appsearch_complocator();
12938     test_appsearch_reglocator();
12939     test_appsearch_inilocator();
12940     test_appsearch_drlocator();
12941     test_featureparents();
12942     test_installprops();
12943     test_launchconditions();
12944     test_ccpsearch();
12945     test_complocator();
12946     test_MsiGetSourcePath();
12947     test_shortlongsource();
12948     test_sourcedir();
12949     test_access();
12950     test_emptypackage();
12951     test_MsiGetProductProperty();
12952     test_MsiSetProperty();
12953     test_MsiApplyMultiplePatches();
12954     test_MsiApplyPatch();
12955
12956     if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
12957     {
12958         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
12959         if (ret)
12960             remove_restore_point(status.llSequenceNumber);
12961     }
12962 }