msi/tests: Fix the scope of todo_wine in the tests for MsiApplyMultiplePatches.
[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 UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR, UINT);
50
51 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
52 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
53
54 static void init_functionpointers(void)
55 {
56     HMODULE hmsi = GetModuleHandleA("msi.dll");
57     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
58     HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
59     HMODULE hshell32 = GetModuleHandleA("shell32.dll");
60     HMODULE hsrclient;
61
62 #define GET_PROC(mod, func) \
63     p ## func = (void*)GetProcAddress(mod, #func);
64
65     GET_PROC(hmsi, MsiApplyMultiplePatchesA);
66     GET_PROC(hmsi, MsiGetComponentPathExA);
67     GET_PROC(hshell32, SHGetFolderPathA);
68
69     GET_PROC(hadvapi32, ConvertSidToStringSidA);
70     GET_PROC(hadvapi32, GetTokenInformation);
71     GET_PROC(hadvapi32, OpenProcessToken);
72     GET_PROC(hadvapi32, RegDeleteKeyExA)
73     GET_PROC(hadvapi32, RegDeleteKeyExW)
74     GET_PROC(hkernel32, IsWow64Process)
75     GET_PROC(hkernel32, GetSystemInfo)
76     GET_PROC(hkernel32, GetSystemWow64DirectoryA)
77
78     hsrclient = LoadLibraryA("srclient.dll");
79     GET_PROC(hsrclient, SRRemoveRestorePoint);
80     GET_PROC(hsrclient, SRSetRestorePointA);
81 #undef GET_PROC
82 }
83
84 static BOOL is_process_limited(void)
85 {
86     HANDLE token;
87
88     if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
89
90     if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
91     {
92         BOOL ret;
93         TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
94         DWORD size;
95
96         ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
97         CloseHandle(token);
98         return (ret && type == TokenElevationTypeLimited);
99     }
100     return FALSE;
101 }
102
103 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
104 {
105     if (pRegDeleteKeyExA)
106         return pRegDeleteKeyExA( key, subkey, access, 0 );
107     return RegDeleteKeyA( key, subkey );
108 }
109
110 static LPSTR get_user_sid(LPSTR *usersid)
111 {
112     HANDLE token;
113     BYTE buf[1024];
114     DWORD size;
115     PTOKEN_USER user;
116
117     if (!pConvertSidToStringSidA)
118     {
119         win_skip("ConvertSidToStringSidA is not available\n");
120         return NULL;
121     }
122
123     *usersid = NULL;
124     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
125     size = sizeof(buf);
126     GetTokenInformation(token, TokenUser, buf, size, &size);
127     user = (PTOKEN_USER)buf;
128     pConvertSidToStringSidA(user->User.Sid, usersid);
129     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
130     CloseHandle(token);
131     return *usersid;
132 }
133
134 /* RegDeleteTreeW from dlls/advapi32/registry.c */
135 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
136 {
137     LONG ret;
138     DWORD dwMaxSubkeyLen, dwMaxValueLen;
139     DWORD dwMaxLen, dwSize;
140     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
141     HKEY hSubKey = hKey;
142
143     if(lpszSubKey)
144     {
145         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
146         if (ret) return ret;
147     }
148
149     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
150             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
151     if (ret) goto cleanup;
152
153     dwMaxSubkeyLen++;
154     dwMaxValueLen++;
155     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
156     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
157     {
158         /* Name too big: alloc a buffer for it */
159         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
160         {
161             ret = ERROR_NOT_ENOUGH_MEMORY;
162             goto cleanup;
163         }
164     }
165
166     /* Recursively delete all the subkeys */
167     while (TRUE)
168     {
169         dwSize = dwMaxLen;
170         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
171                           NULL, NULL, NULL)) break;
172
173         ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
174         if (ret) goto cleanup;
175     }
176
177     if (lpszSubKey)
178     {
179         if (pRegDeleteKeyExW)
180             ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
181         else
182             ret = RegDeleteKeyW(hKey, lpszSubKey);
183     }
184     else
185         while (TRUE)
186         {
187             dwSize = dwMaxLen;
188             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
189                   NULL, NULL, NULL, NULL)) break;
190
191             ret = RegDeleteValueW(hKey, lpszName);
192             if (ret) goto cleanup;
193         }
194
195 cleanup:
196     if (lpszName != szNameBuf)
197         HeapFree(GetProcessHeap(), 0, lpszName);
198     if(lpszSubKey)
199         RegCloseKey(hSubKey);
200     return ret;
201 }
202
203 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
204 {
205     DWORD i,n=1;
206     GUID guid;
207
208     if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
209         return FALSE;
210
211     for(i=0; i<8; i++)
212         out[7-i] = in[n++];
213     n++;
214     for(i=0; i<4; i++)
215         out[11-i] = in[n++];
216     n++;
217     for(i=0; i<4; i++)
218         out[15-i] = in[n++];
219     n++;
220     for(i=0; i<2; i++)
221     {
222         out[17+i*2] = in[n++];
223         out[16+i*2] = in[n++];
224     }
225     n++;
226     for( ; i<8; i++)
227     {
228         out[17+i*2] = in[n++];
229         out[16+i*2] = in[n++];
230     }
231     out[32]=0;
232     return TRUE;
233 }
234
235 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
236 {
237     WCHAR guidW[MAX_PATH];
238     WCHAR squashedW[MAX_PATH];
239     GUID guid;
240     HRESULT hr;
241     int size;
242
243     hr = CoCreateGuid(&guid);
244     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
245
246     size = StringFromGUID2(&guid, guidW, MAX_PATH);
247     ok(size == 39, "Expected 39, got %d\n", hr);
248
249     WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
250     squash_guid(guidW, squashedW);
251     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
252 }
253
254 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
255                                LPCSTR guid, LPSTR usersid, BOOL dir)
256 {
257     WCHAR guidW[MAX_PATH];
258     WCHAR squashedW[MAX_PATH];
259     CHAR squashed[MAX_PATH];
260     CHAR comppath[MAX_PATH];
261     CHAR prodpath[MAX_PATH];
262     CHAR path[MAX_PATH];
263     LPCSTR prod = NULL;
264     HKEY hkey;
265     REGSAM access = KEY_ALL_ACCESS;
266
267     if (is_wow64)
268         access |= KEY_WOW64_64KEY;
269
270     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
271     squash_guid(guidW, squashedW);
272     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
273
274     if (context == MSIINSTALLCONTEXT_MACHINE)
275     {
276         prod = "3D0DAE300FACA1300AD792060BCDAA92";
277         sprintf(comppath,
278                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
279                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
280         lstrcpyA(prodpath,
281                  "SOFTWARE\\Classes\\Installer\\"
282                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
283     }
284     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
285     {
286         prod = "7D2F387510109040002000060BECB6AB";
287         sprintf(comppath,
288                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
289                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
290         sprintf(prodpath,
291                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
292                 "Installer\\%s\\Installer\\Products\\"
293                 "7D2F387510109040002000060BECB6AB", usersid);
294     }
295     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
296     {
297         prod = "7D2F387510109040002000060BECB6AB";
298         sprintf(comppath,
299                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
300                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
301         sprintf(prodpath,
302                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
303                 "Installer\\Managed\\%s\\Installer\\Products\\"
304                 "7D2F387510109040002000060BECB6AB", usersid);
305     }
306
307     RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
308
309     lstrcpyA(path, CURR_DIR);
310     lstrcatA(path, "\\");
311     if (!dir) lstrcatA(path, filename);
312
313     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
314     RegCloseKey(hkey);
315
316     RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
317     RegCloseKey(hkey);
318 }
319
320 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
321 {
322     WCHAR guidW[MAX_PATH];
323     WCHAR squashedW[MAX_PATH];
324     WCHAR substrW[MAX_PATH];
325     CHAR squashed[MAX_PATH];
326     CHAR comppath[MAX_PATH];
327     CHAR prodpath[MAX_PATH];
328     REGSAM access = KEY_ALL_ACCESS;
329
330     if (is_wow64)
331         access |= KEY_WOW64_64KEY;
332
333     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
334     squash_guid(guidW, squashedW);
335     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
336
337     if (context == MSIINSTALLCONTEXT_MACHINE)
338     {
339         sprintf(comppath,
340                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
341                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
342         lstrcpyA(prodpath,
343                  "SOFTWARE\\Classes\\Installer\\"
344                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
345     }
346     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
347     {
348         sprintf(comppath,
349                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
350                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
351         sprintf(prodpath,
352                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
353                 "Installer\\%s\\Installer\\Products\\"
354                 "7D2F387510109040002000060BECB6AB", usersid);
355     }
356     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
357     {
358         sprintf(comppath,
359                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
360                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
361         sprintf(prodpath,
362                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
363                 "Installer\\Managed\\%s\\Installer\\Products\\"
364                 "7D2F387510109040002000060BECB6AB", usersid);
365     }
366
367     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
368     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
369
370     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
371     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
372 }
373
374 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
375 {
376     MSIHANDLE hview = 0;
377     UINT r, ret;
378
379     /* open a select query */
380     r = MsiDatabaseOpenView(hdb, query, &hview);
381     if (r != ERROR_SUCCESS)
382         return r;
383     r = MsiViewExecute(hview, 0);
384     if (r != ERROR_SUCCESS)
385         return r;
386     ret = MsiViewFetch(hview, phrec);
387     r = MsiViewClose(hview);
388     if (r != ERROR_SUCCESS)
389         return r;
390     r = MsiCloseHandle(hview);
391     if (r != ERROR_SUCCESS)
392         return r;
393     return ret;
394 }
395
396 static UINT run_query( MSIHANDLE hdb, const char *query )
397 {
398     MSIHANDLE hview = 0;
399     UINT r;
400
401     r = MsiDatabaseOpenView(hdb, query, &hview);
402     if( r != ERROR_SUCCESS )
403         return r;
404
405     r = MsiViewExecute(hview, 0);
406     if( r == ERROR_SUCCESS )
407         r = MsiViewClose(hview);
408     MsiCloseHandle(hview);
409     return r;
410 }
411
412 static UINT create_component_table( MSIHANDLE hdb )
413 {
414     return run_query( hdb,
415             "CREATE TABLE `Component` ( "
416             "`Component` CHAR(72) NOT NULL, "
417             "`ComponentId` CHAR(38), "
418             "`Directory_` CHAR(72) NOT NULL, "
419             "`Attributes` SHORT NOT NULL, "
420             "`Condition` CHAR(255), "
421             "`KeyPath` CHAR(72) "
422             "PRIMARY KEY `Component`)" );
423 }
424
425 static UINT create_feature_table( MSIHANDLE hdb )
426 {
427     return run_query( hdb,
428             "CREATE TABLE `Feature` ( "
429             "`Feature` CHAR(38) NOT NULL, "
430             "`Feature_Parent` CHAR(38), "
431             "`Title` CHAR(64), "
432             "`Description` CHAR(255), "
433             "`Display` SHORT NOT NULL, "
434             "`Level` SHORT NOT NULL, "
435             "`Directory_` CHAR(72), "
436             "`Attributes` SHORT NOT NULL "
437             "PRIMARY KEY `Feature`)" );
438 }
439
440 static UINT create_feature_components_table( MSIHANDLE hdb )
441 {
442     return run_query( hdb,
443             "CREATE TABLE `FeatureComponents` ( "
444             "`Feature_` CHAR(38) NOT NULL, "
445             "`Component_` CHAR(72) NOT NULL "
446             "PRIMARY KEY `Feature_`, `Component_` )" );
447 }
448
449 static UINT create_file_table( MSIHANDLE hdb )
450 {
451     return run_query( hdb,
452             "CREATE TABLE `File` ("
453             "`File` CHAR(72) NOT NULL, "
454             "`Component_` CHAR(72) NOT NULL, "
455             "`FileName` CHAR(255) NOT NULL, "
456             "`FileSize` LONG NOT NULL, "
457             "`Version` CHAR(72), "
458             "`Language` CHAR(20), "
459             "`Attributes` SHORT, "
460             "`Sequence` SHORT NOT NULL "
461             "PRIMARY KEY `File`)" );
462 }
463
464 static UINT create_remove_file_table( MSIHANDLE hdb )
465 {
466     return run_query( hdb,
467             "CREATE TABLE `RemoveFile` ("
468             "`FileKey` CHAR(72) NOT NULL, "
469             "`Component_` CHAR(72) NOT NULL, "
470             "`FileName` CHAR(255) LOCALIZABLE, "
471             "`DirProperty` CHAR(72) NOT NULL, "
472             "`InstallMode` SHORT NOT NULL "
473             "PRIMARY KEY `FileKey`)" );
474 }
475
476 static UINT create_appsearch_table( MSIHANDLE hdb )
477 {
478     return run_query( hdb,
479             "CREATE TABLE `AppSearch` ("
480             "`Property` CHAR(72) NOT NULL, "
481             "`Signature_` CHAR(72) NOT NULL "
482             "PRIMARY KEY `Property`, `Signature_`)" );
483 }
484
485 static UINT create_reglocator_table( MSIHANDLE hdb )
486 {
487     return run_query( hdb,
488             "CREATE TABLE `RegLocator` ("
489             "`Signature_` CHAR(72) NOT NULL, "
490             "`Root` SHORT NOT NULL, "
491             "`Key` CHAR(255) NOT NULL, "
492             "`Name` CHAR(255), "
493             "`Type` SHORT "
494             "PRIMARY KEY `Signature_`)" );
495 }
496
497 static UINT create_signature_table( MSIHANDLE hdb )
498 {
499     return run_query( hdb,
500             "CREATE TABLE `Signature` ("
501             "`Signature` CHAR(72) NOT NULL, "
502             "`FileName` CHAR(255) NOT NULL, "
503             "`MinVersion` CHAR(20), "
504             "`MaxVersion` CHAR(20), "
505             "`MinSize` LONG, "
506             "`MaxSize` LONG, "
507             "`MinDate` LONG, "
508             "`MaxDate` LONG, "
509             "`Languages` CHAR(255) "
510             "PRIMARY KEY `Signature`)" );
511 }
512
513 static UINT create_launchcondition_table( MSIHANDLE hdb )
514 {
515     return run_query( hdb,
516             "CREATE TABLE `LaunchCondition` ("
517             "`Condition` CHAR(255) NOT NULL, "
518             "`Description` CHAR(255) NOT NULL "
519             "PRIMARY KEY `Condition`)" );
520 }
521
522 static UINT create_property_table( MSIHANDLE hdb )
523 {
524     return run_query( hdb,
525             "CREATE TABLE `Property` ("
526             "`Property` CHAR(72) NOT NULL, "
527             "`Value` CHAR(0) "
528             "PRIMARY KEY `Property`)" );
529 }
530
531 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
532 {
533     return run_query( hdb,
534             "CREATE TABLE `InstallExecuteSequence` ("
535             "`Action` CHAR(72) NOT NULL, "
536             "`Condition` CHAR(255), "
537             "`Sequence` SHORT "
538             "PRIMARY KEY `Action`)" );
539 }
540
541 static UINT create_media_table( MSIHANDLE hdb )
542 {
543     return run_query( hdb,
544             "CREATE TABLE `Media` ("
545             "`DiskId` SHORT NOT NULL, "
546             "`LastSequence` SHORT NOT NULL, "
547             "`DiskPrompt` CHAR(64), "
548             "`Cabinet` CHAR(255), "
549             "`VolumeLabel` CHAR(32), "
550             "`Source` CHAR(72) "
551             "PRIMARY KEY `DiskId`)" );
552 }
553
554 static UINT create_ccpsearch_table( MSIHANDLE hdb )
555 {
556     return run_query( hdb,
557             "CREATE TABLE `CCPSearch` ("
558             "`Signature_` CHAR(72) NOT NULL "
559             "PRIMARY KEY `Signature_`)" );
560 }
561
562 static UINT create_drlocator_table( MSIHANDLE hdb )
563 {
564     return run_query( hdb,
565             "CREATE TABLE `DrLocator` ("
566             "`Signature_` CHAR(72) NOT NULL, "
567             "`Parent` CHAR(72), "
568             "`Path` CHAR(255), "
569             "`Depth` SHORT "
570             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
571 }
572
573 static UINT create_complocator_table( MSIHANDLE hdb )
574 {
575     return run_query( hdb,
576             "CREATE TABLE `CompLocator` ("
577             "`Signature_` CHAR(72) NOT NULL, "
578             "`ComponentId` CHAR(38) NOT NULL, "
579             "`Type` SHORT "
580             "PRIMARY KEY `Signature_`)" );
581 }
582
583 static UINT create_inilocator_table( MSIHANDLE hdb )
584 {
585     return run_query( hdb,
586             "CREATE TABLE `IniLocator` ("
587             "`Signature_` CHAR(72) NOT NULL, "
588             "`FileName` CHAR(255) NOT NULL, "
589             "`Section` CHAR(96)NOT NULL, "
590             "`Key` CHAR(128)NOT NULL, "
591             "`Field` SHORT, "
592             "`Type` SHORT "
593             "PRIMARY KEY `Signature_`)" );
594 }
595
596 #define make_add_entry(type, qtext) \
597     static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
598     { \
599         char insert[] = qtext; \
600         char *query; \
601         UINT sz, r; \
602         sz = strlen(values) + sizeof insert; \
603         query = HeapAlloc(GetProcessHeap(),0,sz); \
604         sprintf(query,insert,values); \
605         r = run_query( hdb, query ); \
606         HeapFree(GetProcessHeap(), 0, query); \
607         return r; \
608     }
609
610 make_add_entry(component,
611                "INSERT INTO `Component`  "
612                "(`Component`, `ComponentId`, `Directory_`, "
613                "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
614
615 make_add_entry(directory,
616                "INSERT INTO `Directory` "
617                "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
618
619 make_add_entry(feature,
620                "INSERT INTO `Feature` "
621                "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
622                "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
623
624 make_add_entry(feature_components,
625                "INSERT INTO `FeatureComponents` "
626                "(`Feature_`, `Component_`) VALUES( %s )")
627
628 make_add_entry(file,
629                "INSERT INTO `File` "
630                "(`File`, `Component_`, `FileName`, `FileSize`, "
631                "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
632
633 make_add_entry(appsearch,
634                "INSERT INTO `AppSearch` "
635                "(`Property`, `Signature_`) VALUES( %s )")
636
637 make_add_entry(signature,
638                "INSERT INTO `Signature` "
639                "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
640                " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
641                "VALUES( %s )")
642
643 make_add_entry(launchcondition,
644                "INSERT INTO `LaunchCondition` "
645                "(`Condition`, `Description`) VALUES( %s )")
646
647 make_add_entry(property,
648                "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
649
650 make_add_entry(install_execute_sequence,
651                "INSERT INTO `InstallExecuteSequence` "
652                "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
653
654 make_add_entry(media,
655                "INSERT INTO `Media` "
656                "(`DiskId`, `LastSequence`, `DiskPrompt`, "
657                "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
658
659 make_add_entry(ccpsearch,
660                "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
661
662 make_add_entry(drlocator,
663                "INSERT INTO `DrLocator` "
664                "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
665
666 make_add_entry(complocator,
667                "INSERT INTO `CompLocator` "
668                "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
669
670 make_add_entry(inilocator,
671                "INSERT INTO `IniLocator` "
672                "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
673                "VALUES( %s )")
674
675 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
676                                   const char *name, UINT type )
677 {
678     const char insert[] =
679         "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
680         "VALUES( '%s', %u, '%s', '%s', %u )";
681     char *query;
682     UINT sz, r;
683
684     sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
685     query = HeapAlloc( GetProcessHeap(), 0, sz );
686     sprintf( query, insert, sig, root, path, name, type );
687     r = run_query( hdb, query );
688     HeapFree( GetProcessHeap(), 0, query );
689     return r;
690 }
691
692 static UINT set_summary_info(MSIHANDLE hdb)
693 {
694     UINT res;
695     MSIHANDLE suminfo;
696
697     /* build summary info */
698     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
699     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
700
701     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
702                         "Installation Database");
703     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
704
705     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
706                         "Installation Database");
707     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
708
709     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
710                         "Wine Hackers");
711     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
712
713     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
714                     ";1033");
715     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
716
717     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
718                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
719     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
720
721     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
722     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
723
724     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
725     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
726
727     res = MsiSummaryInfoPersist(suminfo);
728     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
729
730     res = MsiCloseHandle( suminfo);
731     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
732
733     return res;
734 }
735
736
737 static MSIHANDLE create_package_db(void)
738 {
739     MSIHANDLE hdb = 0;
740     UINT res;
741
742     DeleteFile(msifile);
743
744     /* create an empty database */
745     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
746     ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
747     if( res != ERROR_SUCCESS )
748         return hdb;
749
750     res = MsiDatabaseCommit( hdb );
751     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
752
753     res = set_summary_info(hdb);
754
755     res = run_query( hdb,
756             "CREATE TABLE `Directory` ( "
757             "`Directory` CHAR(255) NOT NULL, "
758             "`Directory_Parent` CHAR(255), "
759             "`DefaultDir` CHAR(255) NOT NULL "
760             "PRIMARY KEY `Directory`)" );
761     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
762
763     return hdb;
764 }
765
766 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
767 {
768     UINT res;
769     CHAR szPackage[12];
770     MSIHANDLE hPackage;
771
772     sprintf(szPackage, "#%u", hdb);
773     res = MsiOpenPackage(szPackage, &hPackage);
774     if (res != ERROR_SUCCESS)
775     {
776         MsiCloseHandle(hdb);
777         return res;
778     }
779
780     res = MsiCloseHandle(hdb);
781     if (res != ERROR_SUCCESS)
782     {
783         MsiCloseHandle(hPackage);
784         return res;
785     }
786
787     *handle = hPackage;
788     return ERROR_SUCCESS;
789 }
790
791 static void create_test_file(const CHAR *name)
792 {
793     HANDLE file;
794     DWORD written;
795
796     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
797     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
798     WriteFile(file, name, strlen(name), &written, NULL);
799     WriteFile(file, "\n", strlen("\n"), &written, NULL);
800     CloseHandle(file);
801 }
802
803 typedef struct _tagVS_VERSIONINFO
804 {
805     WORD wLength;
806     WORD wValueLength;
807     WORD wType;
808     WCHAR szKey[1];
809     WORD wPadding1[1];
810     VS_FIXEDFILEINFO Value;
811     WORD wPadding2[1];
812     WORD wChildren[1];
813 } VS_VERSIONINFO;
814
815 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
816 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
817
818 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
819 {
820     VS_VERSIONINFO *pVerInfo;
821     VS_FIXEDFILEINFO *pFixedInfo;
822     LPBYTE buffer, ofs;
823     CHAR path[MAX_PATH];
824     DWORD handle, size;
825     HANDLE resource;
826     BOOL ret = FALSE;
827
828     GetSystemDirectory(path, MAX_PATH);
829     /* Some dlls can't be updated on Vista/W2K8 */
830     lstrcatA(path, "\\version.dll");
831
832     CopyFileA(path, name, FALSE);
833
834     size = GetFileVersionInfoSize(path, &handle);
835     buffer = HeapAlloc(GetProcessHeap(), 0, size);
836
837     GetFileVersionInfoA(path, 0, size, buffer);
838
839     pVerInfo = (VS_VERSIONINFO *)buffer;
840     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
841     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
842
843     pFixedInfo->dwFileVersionMS = ms;
844     pFixedInfo->dwFileVersionLS = ls;
845     pFixedInfo->dwProductVersionMS = ms;
846     pFixedInfo->dwProductVersionLS = ls;
847
848     resource = BeginUpdateResource(name, FALSE);
849     if (!resource)
850         goto done;
851
852     if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
853                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
854         goto done;
855
856     if (!EndUpdateResource(resource, FALSE))
857         goto done;
858
859     ret = TRUE;
860
861 done:
862     HeapFree(GetProcessHeap(), 0, buffer);
863     return ret;
864 }
865
866 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
867 {
868     RESTOREPOINTINFOA spec;
869
870     spec.dwEventType = event_type;
871     spec.dwRestorePtType = APPLICATION_INSTALL;
872     spec.llSequenceNumber = status->llSequenceNumber;
873     lstrcpyA(spec.szDescription, "msitest restore point");
874
875     return pSRSetRestorePointA(&spec, status);
876 }
877
878 static void remove_restore_point(DWORD seq_number)
879 {
880     DWORD res;
881
882     res = pSRRemoveRestorePoint(seq_number);
883     if (res != ERROR_SUCCESS)
884         trace("Failed to remove the restore point : %08x\n", res);
885 }
886
887 static void test_createpackage(void)
888 {
889     MSIHANDLE hPackage = 0;
890     UINT res;
891
892     res = package_from_db(create_package_db(), &hPackage);
893     if (res == ERROR_INSTALL_PACKAGE_REJECTED)
894     {
895         skip("Not enough rights to perform tests\n");
896         DeleteFile(msifile);
897         return;
898     }
899     ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
900
901     res = MsiCloseHandle( hPackage);
902     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
903     DeleteFile(msifile);
904 }
905
906 static void test_doaction( void )
907 {
908     MSIHANDLE hpkg;
909     UINT r;
910
911     r = MsiDoAction( -1, NULL );
912     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
913
914     r = package_from_db(create_package_db(), &hpkg);
915     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
916     {
917         skip("Not enough rights to perform tests\n");
918         DeleteFile(msifile);
919         return;
920     }
921     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
922
923     r = MsiDoAction(hpkg, NULL);
924     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
925
926     r = MsiDoAction(0, "boo");
927     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
928
929     r = MsiDoAction(hpkg, "boo");
930     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
931
932     MsiCloseHandle( hpkg );
933     DeleteFile(msifile);
934 }
935
936 static void test_gettargetpath_bad(void)
937 {
938     static const WCHAR boo[] = {'b','o','o',0};
939     static const WCHAR empty[] = {0};
940     char buffer[0x80];
941     WCHAR bufferW[0x80];
942     MSIHANDLE hpkg;
943     DWORD sz;
944     UINT r;
945
946     r = package_from_db(create_package_db(), &hpkg);
947     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
948     {
949         skip("Not enough rights to perform tests\n");
950         DeleteFile(msifile);
951         return;
952     }
953     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
954
955     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
956     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
957
958     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
959     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
960
961     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
962     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
963
964     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
965     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
966
967     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
968     ok( r == ERROR_DIRECTORY, "wrong return val\n");
969
970     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
971     ok( r == ERROR_DIRECTORY, "wrong return val\n");
972
973     sz = 0;
974     r = MsiGetTargetPath( hpkg, "", buffer, &sz );
975     ok( r == ERROR_DIRECTORY, "wrong return val\n");
976
977     r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
978     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
979
980     r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
981     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
982
983     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
984     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
985
986     r = MsiGetTargetPathW( 0, boo, NULL, NULL );
987     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
988
989     r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
990     ok( r == ERROR_DIRECTORY, "wrong return val\n");
991
992     r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
993     ok( r == ERROR_DIRECTORY, "wrong return val\n");
994
995     sz = 0;
996     r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
997     ok( r == ERROR_DIRECTORY, "wrong return val\n");
998
999     MsiCloseHandle( hpkg );
1000     DeleteFile(msifile);
1001 }
1002
1003 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1004 {
1005     UINT r;
1006     DWORD size;
1007     MSIHANDLE rec;
1008
1009     rec = MsiCreateRecord( 1 );
1010     ok(rec, "MsiCreate record failed\n");
1011
1012     r = MsiRecordSetString( rec, 0, file );
1013     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1014
1015     size = MAX_PATH;
1016     r = MsiFormatRecord( hpkg, rec, buff, &size );
1017     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1018
1019     MsiCloseHandle( rec );
1020 }
1021
1022 static void test_settargetpath(void)
1023 {
1024     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1025     DWORD sz;
1026     MSIHANDLE hpkg;
1027     UINT r;
1028     MSIHANDLE hdb;
1029
1030     hdb = create_package_db();
1031     ok ( hdb, "failed to create package database\n" );
1032
1033     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1034     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1035
1036     r = create_component_table( hdb );
1037     ok( r == S_OK, "cannot create Component table: %d\n", r );
1038
1039     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1040     ok( r == S_OK, "cannot add dummy component: %d\n", r );
1041
1042     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1043     ok( r == S_OK, "cannot add test component: %d\n", r );
1044
1045     r = create_feature_table( hdb );
1046     ok( r == S_OK, "cannot create Feature table: %d\n", r );
1047
1048     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1049     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1050
1051     r = create_feature_components_table( hdb );
1052     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1053
1054     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1055     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1056
1057     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1058     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1059
1060     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1061     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1062
1063     r = create_file_table( hdb );
1064     ok( r == S_OK, "cannot create File table: %d\n", r );
1065
1066     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1067     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1068
1069     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1070     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1071
1072     r = package_from_db( hdb, &hpkg );
1073     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1074     {
1075         skip("Not enough rights to perform tests\n");
1076         DeleteFile(msifile);
1077         return;
1078     }
1079     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1080
1081     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1082
1083     r = MsiDoAction( hpkg, "CostInitialize");
1084     ok( r == ERROR_SUCCESS, "cost init failed\n");
1085
1086     r = MsiDoAction( hpkg, "FileCost");
1087     ok( r == ERROR_SUCCESS, "file cost failed\n");
1088
1089     r = MsiDoAction( hpkg, "CostFinalize");
1090     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1091
1092     r = MsiSetTargetPath( 0, NULL, NULL );
1093     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1094
1095     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1096     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1097
1098     r = MsiSetTargetPath( hpkg, "boo", NULL );
1099     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1100
1101     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1102     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1103
1104     sz = sizeof tempdir - 1;
1105     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1106     sprintf( file, "%srootfile.txt", tempdir );
1107     buffer[0] = 0;
1108     query_file_path( hpkg, "[#RootFile]", buffer );
1109     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1110     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1111
1112     GetTempFileName( tempdir, "_wt", 0, buffer );
1113     sprintf( tempdir, "%s\\subdir", buffer );
1114
1115     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1116     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1117         "MsiSetTargetPath on file returned %d\n", r );
1118
1119     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1120     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1121         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1122
1123     DeleteFile( buffer );
1124
1125     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1126     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1127
1128     r = GetFileAttributes( buffer );
1129     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1130
1131     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1132     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1133
1134     sz = sizeof buffer - 1;
1135     lstrcat( tempdir, "\\" );
1136     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1137     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1138     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1139
1140     sprintf( file, "%srootfile.txt", tempdir );
1141     query_file_path( hpkg, "[#RootFile]", buffer );
1142     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1143
1144     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1145     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1146
1147     query_file_path( hpkg, "[#TestFile]", buffer );
1148     ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1149         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1150
1151     sz = sizeof buffer - 1;
1152     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1153     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1154     ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1155
1156     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1157     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1158
1159     sz = sizeof buffer - 1;
1160     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1161     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1162     ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1163
1164     MsiCloseHandle( hpkg );
1165 }
1166
1167 static void test_condition(void)
1168 {
1169     static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1170     static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1171     static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1172     static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1173     MSICONDITION r;
1174     MSIHANDLE hpkg;
1175
1176     r = package_from_db(create_package_db(), &hpkg);
1177     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1178     {
1179         skip("Not enough rights to perform tests\n");
1180         DeleteFile(msifile);
1181         return;
1182     }
1183     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1184
1185     r = MsiEvaluateCondition(0, NULL);
1186     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1187
1188     r = MsiEvaluateCondition(hpkg, NULL);
1189     ok( r == MSICONDITION_NONE, "wrong return val\n");
1190
1191     r = MsiEvaluateCondition(hpkg, "");
1192     ok( r == MSICONDITION_NONE, "wrong return val\n");
1193
1194     r = MsiEvaluateCondition(hpkg, "1");
1195     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1196
1197     r = MsiEvaluateCondition(hpkg, "0");
1198     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1199
1200     r = MsiEvaluateCondition(hpkg, "-1");
1201     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1202
1203     r = MsiEvaluateCondition(hpkg, "0 = 0");
1204     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1205
1206     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1207     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1208
1209     r = MsiEvaluateCondition(hpkg, "0 = 1");
1210     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1211
1212     r = MsiEvaluateCondition(hpkg, "0 > 1");
1213     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1214
1215     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1216     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1217
1218     r = MsiEvaluateCondition(hpkg, "1 > 1");
1219     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1220
1221     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1222     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1223
1224     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1225     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1226
1227     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1228     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1229
1230     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1231     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1232
1233     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1234     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1235
1236     r = MsiEvaluateCondition(hpkg, "0 < 1");
1237     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1238
1239     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1240     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1241
1242     r = MsiEvaluateCondition(hpkg, "1 < 1");
1243     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1244
1245     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1246     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1247
1248     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1249     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1250
1251     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1252     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1253
1254     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1255     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1256
1257     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1258     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1259
1260     r = MsiEvaluateCondition(hpkg, "0 >=");
1261     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1262
1263     r = MsiEvaluateCondition(hpkg, " ");
1264     ok( r == MSICONDITION_NONE, "wrong return val\n");
1265
1266     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1267     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1268
1269     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1270     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1271
1272     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1273     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1274
1275     r = MsiEvaluateCondition(hpkg, "not 0");
1276     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1277
1278     r = MsiEvaluateCondition(hpkg, "not LicView");
1279     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1280
1281     r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1282     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1283
1284     r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1285     ok (r == MSICONDITION_FALSE, "wrong return val\n");
1286
1287     r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1288     ok (r == MSICONDITION_TRUE, "wrong return val\n");
1289
1290     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1291     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1292
1293     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1294     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1295
1296     r = MsiEvaluateCondition(hpkg, "\"0\"");
1297     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1298
1299     r = MsiEvaluateCondition(hpkg, "1 and 2");
1300     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1301
1302     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1303     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1304
1305     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1306     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1307
1308     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1309     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1310
1311     r = MsiEvaluateCondition(hpkg, "(0)");
1312     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1313
1314     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1315     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1316
1317     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1318     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1319
1320     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1321     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1322
1323     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1324     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1325
1326     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1327     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1328
1329     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1330     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1331
1332     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1333     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1334
1335     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1336     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1337
1338     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1339     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1340
1341     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1342     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1343
1344     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1345     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1346
1347     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1348     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1349
1350     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1351     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1352
1353     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1354     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1355
1356     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1357     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1358
1359     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1360     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1361
1362     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1363     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1364
1365     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1366     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1367
1368     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1369     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1370
1371     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1372     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1373
1374     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1375     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1376
1377     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1378     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1379
1380     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1381     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1382
1383     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1384     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1385
1386     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1387     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1388
1389     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1390     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1391
1392     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1393     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1394
1395     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1396     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1397
1398     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1399     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1400
1401     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1402     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1403
1404     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1405     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1406
1407     MsiSetProperty(hpkg, "mm", "5" );
1408
1409     r = MsiEvaluateCondition(hpkg, "mm = 5");
1410     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1411
1412     r = MsiEvaluateCondition(hpkg, "mm < 6");
1413     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1414
1415     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1416     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1417
1418     r = MsiEvaluateCondition(hpkg, "mm > 4");
1419     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1420
1421     r = MsiEvaluateCondition(hpkg, "mm < 12");
1422     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1423
1424     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1425     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1426
1427     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1428     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1429
1430     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1431     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1432
1433     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1434     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1435
1436     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1437     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1438
1439     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1440     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1441
1442     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1443     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1444
1445     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1446     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1447
1448     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1449     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1450
1451     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1452     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1453
1454     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1455     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1456
1457     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1458     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1459
1460     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1461     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1462
1463     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1464     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1465
1466     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1467     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1468
1469     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1470     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1471
1472     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1473     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1474
1475     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1476     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1477
1478     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1479     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1480
1481     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1482     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1483
1484     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1485     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1486
1487     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1488     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1489
1490     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1491     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1492
1493     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1494     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1495
1496     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1497     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1498
1499     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1500     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1501
1502     MsiSetProperty(hpkg, "bandalmael", "0" );
1503     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1504     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1505
1506     MsiSetProperty(hpkg, "bandalmael", "" );
1507     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1508     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1509
1510     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1511     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1512     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1513
1514     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1515     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1516     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1517
1518     MsiSetProperty(hpkg, "bandalmael", "0 " );
1519     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1520     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1521
1522     MsiSetProperty(hpkg, "bandalmael", "-0" );
1523     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1524     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1525
1526     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1527     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1528     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1529
1530     MsiSetProperty(hpkg, "bandalmael", "--0" );
1531     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1532     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1533
1534     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1535     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1536     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1537
1538     MsiSetProperty(hpkg, "bandalmael", "-" );
1539     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1540     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1541
1542     MsiSetProperty(hpkg, "bandalmael", "+0" );
1543     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1544     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1545
1546     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1547     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1548     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1549     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1550     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1551
1552     MsiSetProperty(hpkg, "one", "hi");
1553     MsiSetProperty(hpkg, "two", "hithere");
1554     r = MsiEvaluateCondition(hpkg, "one >< two");
1555     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1556
1557     MsiSetProperty(hpkg, "one", "hithere");
1558     MsiSetProperty(hpkg, "two", "hi");
1559     r = MsiEvaluateCondition(hpkg, "one >< two");
1560     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1561
1562     MsiSetProperty(hpkg, "one", "hello");
1563     MsiSetProperty(hpkg, "two", "hi");
1564     r = MsiEvaluateCondition(hpkg, "one >< two");
1565     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1566
1567     MsiSetProperty(hpkg, "one", "hellohithere");
1568     MsiSetProperty(hpkg, "two", "hi");
1569     r = MsiEvaluateCondition(hpkg, "one >< two");
1570     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1571
1572     MsiSetProperty(hpkg, "one", "");
1573     MsiSetProperty(hpkg, "two", "hi");
1574     r = MsiEvaluateCondition(hpkg, "one >< two");
1575     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1576
1577     MsiSetProperty(hpkg, "one", "hi");
1578     MsiSetProperty(hpkg, "two", "");
1579     r = MsiEvaluateCondition(hpkg, "one >< two");
1580     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1581
1582     MsiSetProperty(hpkg, "one", "");
1583     MsiSetProperty(hpkg, "two", "");
1584     r = MsiEvaluateCondition(hpkg, "one >< two");
1585     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1586
1587     MsiSetProperty(hpkg, "one", "1234");
1588     MsiSetProperty(hpkg, "two", "1");
1589     r = MsiEvaluateCondition(hpkg, "one >< two");
1590     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1591
1592     MsiSetProperty(hpkg, "one", "one 1234");
1593     MsiSetProperty(hpkg, "two", "1");
1594     r = MsiEvaluateCondition(hpkg, "one >< two");
1595     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1596
1597     MsiSetProperty(hpkg, "one", "hithere");
1598     MsiSetProperty(hpkg, "two", "hi");
1599     r = MsiEvaluateCondition(hpkg, "one << two");
1600     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1601
1602     MsiSetProperty(hpkg, "one", "hi");
1603     MsiSetProperty(hpkg, "two", "hithere");
1604     r = MsiEvaluateCondition(hpkg, "one << two");
1605     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1606
1607     MsiSetProperty(hpkg, "one", "hi");
1608     MsiSetProperty(hpkg, "two", "hi");
1609     r = MsiEvaluateCondition(hpkg, "one << two");
1610     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1611
1612     MsiSetProperty(hpkg, "one", "abcdhithere");
1613     MsiSetProperty(hpkg, "two", "hi");
1614     r = MsiEvaluateCondition(hpkg, "one << two");
1615     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1616
1617     MsiSetProperty(hpkg, "one", "");
1618     MsiSetProperty(hpkg, "two", "hi");
1619     r = MsiEvaluateCondition(hpkg, "one << two");
1620     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1621
1622     MsiSetProperty(hpkg, "one", "hithere");
1623     MsiSetProperty(hpkg, "two", "");
1624     r = MsiEvaluateCondition(hpkg, "one << two");
1625     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1626
1627     MsiSetProperty(hpkg, "one", "");
1628     MsiSetProperty(hpkg, "two", "");
1629     r = MsiEvaluateCondition(hpkg, "one << two");
1630     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1631
1632     MsiSetProperty(hpkg, "one", "1234");
1633     MsiSetProperty(hpkg, "two", "1");
1634     r = MsiEvaluateCondition(hpkg, "one << two");
1635     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1636
1637     MsiSetProperty(hpkg, "one", "1234 one");
1638     MsiSetProperty(hpkg, "two", "1");
1639     r = MsiEvaluateCondition(hpkg, "one << two");
1640     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1641
1642     MsiSetProperty(hpkg, "one", "hithere");
1643     MsiSetProperty(hpkg, "two", "there");
1644     r = MsiEvaluateCondition(hpkg, "one >> two");
1645     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1646
1647     MsiSetProperty(hpkg, "one", "hithere");
1648     MsiSetProperty(hpkg, "two", "hi");
1649     r = MsiEvaluateCondition(hpkg, "one >> two");
1650     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1651
1652     MsiSetProperty(hpkg, "one", "there");
1653     MsiSetProperty(hpkg, "two", "hithere");
1654     r = MsiEvaluateCondition(hpkg, "one >> two");
1655     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1656
1657     MsiSetProperty(hpkg, "one", "there");
1658     MsiSetProperty(hpkg, "two", "there");
1659     r = MsiEvaluateCondition(hpkg, "one >> two");
1660     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1661
1662     MsiSetProperty(hpkg, "one", "abcdhithere");
1663     MsiSetProperty(hpkg, "two", "hi");
1664     r = MsiEvaluateCondition(hpkg, "one >> two");
1665     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1666
1667     MsiSetProperty(hpkg, "one", "");
1668     MsiSetProperty(hpkg, "two", "there");
1669     r = MsiEvaluateCondition(hpkg, "one >> two");
1670     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1671
1672     MsiSetProperty(hpkg, "one", "there");
1673     MsiSetProperty(hpkg, "two", "");
1674     r = MsiEvaluateCondition(hpkg, "one >> two");
1675     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1676
1677     MsiSetProperty(hpkg, "one", "");
1678     MsiSetProperty(hpkg, "two", "");
1679     r = MsiEvaluateCondition(hpkg, "one >> two");
1680     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1681
1682     MsiSetProperty(hpkg, "one", "1234");
1683     MsiSetProperty(hpkg, "two", "4");
1684     r = MsiEvaluateCondition(hpkg, "one >> two");
1685     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1686
1687     MsiSetProperty(hpkg, "one", "one 1234");
1688     MsiSetProperty(hpkg, "two", "4");
1689     r = MsiEvaluateCondition(hpkg, "one >> two");
1690     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1691
1692     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1693
1694     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1695     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1696
1697     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1698     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1699
1700     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1701     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1702
1703     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1704     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1705
1706     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1707     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1708
1709     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1710     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1711
1712     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1713     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1714
1715     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1716     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1717
1718     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1719     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1720
1721     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1722     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1723
1724     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1725     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1726
1727     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1728     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1729
1730     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1731     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1732
1733     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1734     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1735
1736     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1737     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1738
1739     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1740     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1741
1742     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1743     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1744
1745     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1746     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1747
1748     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1749     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1750
1751     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1752     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1753
1754     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1755     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1756
1757     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1758     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1759
1760     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1761     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1762
1763     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1764     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1765
1766     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1767     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1768
1769     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1770     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1771
1772     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1773     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1774
1775     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1776     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1777
1778     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1779     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1780
1781     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1782     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1783
1784     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1785     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1786
1787     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1788     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1789
1790     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1791     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1792
1793     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1794     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1795
1796     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1797     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1798
1799     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1800     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1801
1802     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1803     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1804
1805     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1806     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1807     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1808
1809     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1810     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1811
1812     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1813     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1814
1815     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1816     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1817
1818     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1819     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1820
1821     MsiSetProperty(hpkg, "one", "1");
1822     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1823     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1824
1825     MsiSetProperty(hpkg, "X", "5.0");
1826
1827     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1828     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1829
1830     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1831     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1832
1833     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1834     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1835
1836     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1837     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1838
1839     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1840     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1841
1842     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1843     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1844
1845     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1846     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1847
1848     /* feature doesn't exist */
1849     r = MsiEvaluateCondition(hpkg, "&nofeature");
1850     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1851
1852     MsiSetProperty(hpkg, "A", "2");
1853     MsiSetProperty(hpkg, "X", "50");
1854
1855     r = MsiEvaluateCondition(hpkg, "2 <= X");
1856     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1857
1858     r = MsiEvaluateCondition(hpkg, "A <= X");
1859     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1860
1861     r = MsiEvaluateCondition(hpkg, "A <= 50");
1862     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1863
1864     MsiSetProperty(hpkg, "X", "50val");
1865
1866     r = MsiEvaluateCondition(hpkg, "2 <= X");
1867     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1868
1869     r = MsiEvaluateCondition(hpkg, "A <= X");
1870     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1871
1872     MsiSetProperty(hpkg, "A", "7");
1873     MsiSetProperty(hpkg, "X", "50");
1874
1875     r = MsiEvaluateCondition(hpkg, "7 <= X");
1876     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1877
1878     r = MsiEvaluateCondition(hpkg, "A <= X");
1879     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1880
1881     r = MsiEvaluateCondition(hpkg, "A <= 50");
1882     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1883
1884     MsiSetProperty(hpkg, "X", "50val");
1885
1886     r = MsiEvaluateCondition(hpkg, "2 <= X");
1887     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1888
1889     r = MsiEvaluateCondition(hpkg, "A <= X");
1890     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1891
1892     r = MsiEvaluateConditionW(hpkg, cond1);
1893     ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1894         "wrong return val (%d)\n", r);
1895
1896     r = MsiEvaluateConditionW(hpkg, cond2);
1897     ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1898         "wrong return val (%d)\n", r);
1899
1900     r = MsiEvaluateConditionW(hpkg, cond3);
1901     ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1902         "wrong return val (%d)\n", r);
1903
1904     r = MsiEvaluateConditionW(hpkg, cond4);
1905     ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1906         "wrong return val (%d)\n", r);
1907
1908     MsiCloseHandle( hpkg );
1909     DeleteFile(msifile);
1910 }
1911
1912 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1913 {
1914     UINT r;
1915     DWORD sz;
1916     char buffer[2];
1917
1918     sz = sizeof buffer;
1919     strcpy(buffer,"x");
1920     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1921     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1922 }
1923
1924 static void test_props(void)
1925 {
1926     MSIHANDLE hpkg, hdb;
1927     UINT r;
1928     DWORD sz;
1929     char buffer[0x100];
1930
1931     hdb = create_package_db();
1932     r = run_query( hdb,
1933             "CREATE TABLE `Property` ( "
1934             "`Property` CHAR(255) NOT NULL, "
1935             "`Value` CHAR(255) "
1936             "PRIMARY KEY `Property`)" );
1937     ok( r == ERROR_SUCCESS , "Failed\n" );
1938
1939     r = run_query(hdb,
1940             "INSERT INTO `Property` "
1941             "(`Property`, `Value`) "
1942             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1943     ok( r == ERROR_SUCCESS , "Failed\n" );
1944
1945     r = package_from_db( hdb, &hpkg );
1946     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1947     {
1948         skip("Not enough rights to perform tests\n");
1949         DeleteFile(msifile);
1950         return;
1951     }
1952     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1953
1954     /* test invalid values */
1955     r = MsiGetProperty( 0, NULL, NULL, NULL );
1956     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1957
1958     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1959     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1960
1961     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1962     ok( r == ERROR_SUCCESS, "wrong return val\n");
1963
1964     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1965     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1966
1967     /* test retrieving an empty/nonexistent property */
1968     sz = sizeof buffer;
1969     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1970     ok( r == ERROR_SUCCESS, "wrong return val\n");
1971     ok( sz == 0, "wrong size returned\n");
1972
1973     check_prop_empty( hpkg, "boo");
1974     sz = 0;
1975     strcpy(buffer,"x");
1976     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1977     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1978     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1979     ok( sz == 0, "wrong size returned\n");
1980
1981     sz = 1;
1982     strcpy(buffer,"x");
1983     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1984     ok( r == ERROR_SUCCESS, "wrong return val\n");
1985     ok( buffer[0] == 0, "buffer was not changed\n");
1986     ok( sz == 0, "wrong size returned\n");
1987
1988     /* set the property to something */
1989     r = MsiSetProperty( 0, NULL, NULL );
1990     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1991
1992     r = MsiSetProperty( hpkg, NULL, NULL );
1993     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1994
1995     r = MsiSetProperty( hpkg, "", NULL );
1996     ok( r == ERROR_SUCCESS, "wrong return val\n");
1997
1998     /* try set and get some illegal property identifiers */
1999     r = MsiSetProperty( hpkg, "", "asdf" );
2000     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2001
2002     r = MsiSetProperty( hpkg, "=", "asdf" );
2003     ok( r == ERROR_SUCCESS, "wrong return val\n");
2004
2005     r = MsiSetProperty( hpkg, " ", "asdf" );
2006     ok( r == ERROR_SUCCESS, "wrong return val\n");
2007
2008     r = MsiSetProperty( hpkg, "'", "asdf" );
2009     ok( r == ERROR_SUCCESS, "wrong return val\n");
2010
2011     sz = sizeof buffer;
2012     buffer[0]=0;
2013     r = MsiGetProperty( hpkg, "'", buffer, &sz );
2014     ok( r == ERROR_SUCCESS, "wrong return val\n");
2015     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2016
2017     /* set empty values */
2018     r = MsiSetProperty( hpkg, "boo", NULL );
2019     ok( r == ERROR_SUCCESS, "wrong return val\n");
2020     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2021
2022     r = MsiSetProperty( hpkg, "boo", "" );
2023     ok( r == ERROR_SUCCESS, "wrong return val\n");
2024     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2025
2026     /* set a non-empty value */
2027     r = MsiSetProperty( hpkg, "boo", "xyz" );
2028     ok( r == ERROR_SUCCESS, "wrong return val\n");
2029
2030     sz = 1;
2031     strcpy(buffer,"x");
2032     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2033     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2034     ok( buffer[0] == 0, "buffer was not changed\n");
2035     ok( sz == 3, "wrong size returned\n");
2036
2037     sz = 4;
2038     strcpy(buffer,"x");
2039     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2040     ok( r == ERROR_SUCCESS, "wrong return val\n");
2041     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2042     ok( sz == 3, "wrong size returned\n");
2043
2044     sz = 3;
2045     strcpy(buffer,"x");
2046     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2047     ok( r == ERROR_MORE_DATA, "wrong return val\n");
2048     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2049     ok( sz == 3, "wrong size returned\n");
2050
2051     r = MsiSetProperty(hpkg, "SourceDir", "foo");
2052     ok( r == ERROR_SUCCESS, "wrong return val\n");
2053
2054     sz = 4;
2055     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2056     ok( r == ERROR_SUCCESS, "wrong return val\n");
2057     ok( !strcmp(buffer,""), "buffer wrong\n");
2058     ok( sz == 0, "wrong size returned\n");
2059
2060     sz = 4;
2061     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2062     ok( r == ERROR_SUCCESS, "wrong return val\n");
2063     ok( !strcmp(buffer,""), "buffer wrong\n");
2064     ok( sz == 0, "wrong size returned\n");
2065
2066     sz = 4;
2067     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2068     ok( r == ERROR_SUCCESS, "wrong return val\n");
2069     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2070     ok( sz == 3, "wrong size returned\n");
2071
2072     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2073     ok( r == ERROR_SUCCESS, "wrong return val\n");
2074
2075     sz = 0;
2076     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2077     ok( r == ERROR_SUCCESS, "return wrong\n");
2078     ok( sz == 13, "size wrong (%d)\n", sz);
2079
2080     sz = 13;
2081     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2082     ok( r == ERROR_MORE_DATA, "return wrong\n");
2083     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2084
2085     r = MsiSetProperty(hpkg, "property", "value");
2086     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2087
2088     sz = 6;
2089     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2090     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2091     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2092
2093     r = MsiSetProperty(hpkg, "property", NULL);
2094     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2095
2096     sz = 6;
2097     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2099     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2100
2101     MsiCloseHandle( hpkg );
2102     DeleteFile(msifile);
2103 }
2104
2105 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2106 {
2107     MSIHANDLE hview, hrec;
2108     BOOL found;
2109     CHAR buffer[MAX_PATH];
2110     DWORD sz;
2111     UINT r;
2112
2113     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2114     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2115     r = MsiViewExecute(hview, 0);
2116     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2117
2118     found = FALSE;
2119     while (r == ERROR_SUCCESS && !found)
2120     {
2121         r = MsiViewFetch(hview, &hrec);
2122         if (r != ERROR_SUCCESS) break;
2123
2124         sz = MAX_PATH;
2125         r = MsiRecordGetString(hrec, 1, buffer, &sz);
2126         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2127         {
2128             sz = MAX_PATH;
2129             r = MsiRecordGetString(hrec, 2, buffer, &sz);
2130             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2131                 found = TRUE;
2132         }
2133
2134         MsiCloseHandle(hrec);
2135     }
2136
2137     MsiViewClose(hview);
2138     MsiCloseHandle(hview);
2139
2140     return found;
2141 }
2142
2143 static void test_property_table(void)
2144 {
2145     const char *query;
2146     UINT r;
2147     MSIHANDLE hpkg, hdb, hrec;
2148     char buffer[MAX_PATH], package[10];
2149     DWORD sz;
2150     BOOL found;
2151
2152     hdb = create_package_db();
2153     ok( hdb, "failed to create package\n");
2154
2155     r = package_from_db(hdb, &hpkg);
2156     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2157     {
2158         skip("Not enough rights to perform tests\n");
2159         DeleteFile(msifile);
2160         return;
2161     }
2162     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2163
2164     MsiCloseHandle(hdb);
2165
2166     hdb = MsiGetActiveDatabase(hpkg);
2167
2168     query = "CREATE TABLE `_Property` ( "
2169         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2170     r = run_query(hdb, query);
2171     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2172
2173     MsiCloseHandle(hdb);
2174     MsiCloseHandle(hpkg);
2175     DeleteFile(msifile);
2176
2177     hdb = create_package_db();
2178     ok( hdb, "failed to create package\n");
2179
2180     query = "CREATE TABLE `_Property` ( "
2181         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2182     r = run_query(hdb, query);
2183     ok(r == ERROR_SUCCESS, "failed to create table\n");
2184
2185     query = "ALTER `_Property` ADD `foo` INTEGER";
2186     r = run_query(hdb, query);
2187     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2188
2189     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2190     r = run_query(hdb, query);
2191     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2192
2193     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2194     r = run_query(hdb, query);
2195     ok(r == ERROR_SUCCESS, "failed to add column\n");
2196
2197     sprintf(package, "#%i", hdb);
2198     r = MsiOpenPackage(package, &hpkg);
2199     todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2200     if (r == ERROR_SUCCESS)
2201         MsiCloseHandle(hpkg);
2202
2203     r = MsiCloseHandle(hdb);
2204     ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2205
2206     hdb = create_package_db();
2207     ok (hdb, "failed to create package database\n");
2208
2209     r = create_property_table(hdb);
2210     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2211
2212     r = add_property_entry(hdb, "'prop', 'val'");
2213     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2214
2215     r = package_from_db(hdb, &hpkg);
2216     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2217
2218     MsiCloseHandle(hdb);
2219
2220     sz = MAX_PATH;
2221     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2222     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2223     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2224
2225     hdb = MsiGetActiveDatabase(hpkg);
2226
2227     found = find_prop_in_property(hdb, "prop", "val");
2228     ok(found, "prop should be in the _Property table\n");
2229
2230     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2231     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2232
2233     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2234     r = do_query(hdb, query, &hrec);
2235     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2236
2237     found = find_prop_in_property(hdb, "dantes", "mercedes");
2238     ok(found == FALSE, "dantes should not be in the _Property table\n");
2239
2240     sz = MAX_PATH;
2241     lstrcpy(buffer, "aaa");
2242     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2243     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2244     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2245
2246     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2247     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2248
2249     found = find_prop_in_property(hdb, "dantes", "mercedes");
2250     ok(found == TRUE, "dantes should be in the _Property table\n");
2251
2252     MsiCloseHandle(hdb);
2253     MsiCloseHandle(hpkg);
2254     DeleteFile(msifile);
2255 }
2256
2257 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2258 {
2259     MSIHANDLE htab = 0;
2260     UINT res;
2261
2262     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2263     if( res == ERROR_SUCCESS )
2264     {
2265         UINT r;
2266
2267         r = MsiViewExecute( htab, hrec );
2268         if( r != ERROR_SUCCESS )
2269         {
2270             res = r;
2271             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2272         }
2273
2274         r = MsiViewClose( htab );
2275         if( r != ERROR_SUCCESS )
2276             res = r;
2277
2278         r = MsiCloseHandle( htab );
2279         if( r != ERROR_SUCCESS )
2280             res = r;
2281     }
2282     return res;
2283 }
2284
2285 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2286 {
2287     return try_query_param( hdb, szQuery, 0 );
2288 }
2289
2290 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2291 {
2292     MSIHANDLE summary;
2293     UINT r;
2294
2295     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2296     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2297
2298     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2299     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2300
2301     r = MsiSummaryInfoPersist(summary);
2302     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2303
2304     MsiCloseHandle(summary);
2305 }
2306
2307 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2308 {
2309     MSIHANDLE summary;
2310     UINT r;
2311
2312     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2314
2315     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2316     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2317
2318     r = MsiSummaryInfoPersist(summary);
2319     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2320
2321     MsiCloseHandle(summary);
2322 }
2323
2324 static void test_msipackage(void)
2325 {
2326     MSIHANDLE hdb = 0, hpack = 100;
2327     UINT r;
2328     const char *query;
2329     char name[10];
2330
2331     /* NULL szPackagePath */
2332     r = MsiOpenPackage(NULL, &hpack);
2333     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2334
2335     /* empty szPackagePath */
2336     r = MsiOpenPackage("", &hpack);
2337     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2338     {
2339         skip("Not enough rights to perform tests\n");
2340         return;
2341     }
2342     todo_wine
2343     {
2344         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2345     }
2346
2347     if (r == ERROR_SUCCESS)
2348         MsiCloseHandle(hpack);
2349
2350     /* nonexistent szPackagePath */
2351     r = MsiOpenPackage("nonexistent", &hpack);
2352     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2353
2354     /* NULL hProduct */
2355     r = MsiOpenPackage(msifile, NULL);
2356     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2357
2358     name[0]='#';
2359     name[1]=0;
2360     r = MsiOpenPackage(name, &hpack);
2361     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2362
2363     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2364     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2365
2366     /* database exists, but is emtpy */
2367     sprintf(name, "#%d", hdb);
2368     r = MsiOpenPackage(name, &hpack);
2369     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2370        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2371
2372     query = "CREATE TABLE `Property` ( "
2373             "`Property` CHAR(72), `Value` CHAR(0) "
2374             "PRIMARY KEY `Property`)";
2375     r = try_query(hdb, query);
2376     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2377
2378     query = "CREATE TABLE `InstallExecuteSequence` ("
2379             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2380             "PRIMARY KEY `Action`)";
2381     r = try_query(hdb, query);
2382     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2383
2384     /* a few key tables exist */
2385     sprintf(name, "#%d", hdb);
2386     r = MsiOpenPackage(name, &hpack);
2387     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2388        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2389
2390     MsiCloseHandle(hdb);
2391     DeleteFile(msifile);
2392
2393     /* start with a clean database to show what constitutes a valid package */
2394     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2395     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2396
2397     sprintf(name, "#%d", hdb);
2398
2399     /* The following summary information props must exist:
2400      *  - PID_REVNUMBER
2401      *  - PID_PAGECOUNT
2402      */
2403
2404     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2405     r = MsiOpenPackage(name, &hpack);
2406     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2407        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2408
2409     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2410     r = MsiOpenPackage(name, &hpack);
2411     ok(r == ERROR_SUCCESS,
2412        "Expected ERROR_SUCCESS, got %d\n", r);
2413
2414     MsiCloseHandle(hpack);
2415     MsiCloseHandle(hdb);
2416     DeleteFile(msifile);
2417 }
2418
2419 static void test_formatrecord2(void)
2420 {
2421     MSIHANDLE hpkg, hrec ;
2422     char buffer[0x100];
2423     DWORD sz;
2424     UINT r;
2425
2426     r = package_from_db(create_package_db(), &hpkg);
2427     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2428     {
2429         skip("Not enough rights to perform tests\n");
2430         DeleteFile(msifile);
2431         return;
2432     }
2433     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2434
2435     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2436     ok( r == ERROR_SUCCESS, "set property failed\n");
2437
2438     hrec = MsiCreateRecord(2);
2439     ok(hrec, "create record failed\n");
2440
2441     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2442     ok( r == ERROR_SUCCESS, "format record failed\n");
2443
2444     buffer[0] = 0;
2445     sz = sizeof buffer;
2446     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2447
2448     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2449     r = MsiRecordSetString(hrec, 1, "hoo");
2450     sz = sizeof buffer;
2451     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2452     ok( sz == 3, "size wrong\n");
2453     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2454     ok( r == ERROR_SUCCESS, "format failed\n");
2455
2456     r = MsiRecordSetString(hrec, 0, "x[~]x");
2457     sz = sizeof buffer;
2458     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2459     ok( sz == 3, "size wrong\n");
2460     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2461     ok( r == ERROR_SUCCESS, "format failed\n");
2462
2463     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2464     r = MsiRecordSetString(hrec, 1, "hoo");
2465     sz = sizeof buffer;
2466     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2467     ok( sz == 3, "size wrong\n");
2468     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2469     ok( r == ERROR_SUCCESS, "format failed\n");
2470
2471     r = MsiRecordSetString(hrec, 0, "[\\[]");
2472     sz = sizeof buffer;
2473     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2474     ok( sz == 1, "size wrong\n");
2475     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2476     ok( r == ERROR_SUCCESS, "format failed\n");
2477
2478     SetEnvironmentVariable("FOO", "BAR");
2479     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2480     sz = sizeof buffer;
2481     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2482     ok( sz == 3, "size wrong\n");
2483     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2484     ok( r == ERROR_SUCCESS, "format failed\n");
2485
2486     r = MsiRecordSetString(hrec, 0, "[[1]]");
2487     r = MsiRecordSetString(hrec, 1, "%FOO");
2488     sz = sizeof buffer;
2489     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2490     ok( sz == 3, "size wrong\n");
2491     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2492     ok( r == ERROR_SUCCESS, "format failed\n");
2493
2494     MsiCloseHandle( hrec );
2495     MsiCloseHandle( hpkg );
2496     DeleteFile(msifile);
2497 }
2498
2499 static void test_states(void)
2500 {
2501     MSIHANDLE hpkg;
2502     UINT r;
2503     MSIHANDLE hdb;
2504     INSTALLSTATE state, action;
2505
2506     static const CHAR msifile2[] = "winetest2-package.msi";
2507     static const CHAR msifile3[] = "winetest3-package.msi";
2508     static const CHAR msifile4[] = "winetest4-package.msi";
2509
2510     if (is_process_limited())
2511     {
2512         skip("process is limited\n");
2513         return;
2514     }
2515
2516     hdb = create_package_db();
2517     ok ( hdb, "failed to create package database\n" );
2518
2519     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2520     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2521
2522     r = create_property_table( hdb );
2523     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2524
2525     r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2526     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2527
2528     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2529     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2530
2531     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2532     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2533
2534     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2535     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2536
2537     r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2538     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2539
2540     r = create_install_execute_sequence_table( hdb );
2541     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2542
2543     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2544     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2545
2546     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2547     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2548
2549     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2550     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2551
2552     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2553     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2554
2555     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2556     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2557
2558     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2559     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2560
2561     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2562     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2563
2564     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2565     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2566
2567     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2568     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2569
2570     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2571     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2572
2573     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2574     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2575
2576     r = create_media_table( hdb );
2577     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2578
2579     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2580     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2581
2582     r = create_feature_table( hdb );
2583     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2584
2585     r = create_component_table( hdb );
2586     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2587
2588     /* msidbFeatureAttributesFavorLocal */
2589     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2590     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2591
2592     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2593     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2594     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2595
2596     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2597     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2598     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2599
2600     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2601     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2602     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2603
2604     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2605     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2606     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2607
2608     /* msidbFeatureAttributesFavorSource */
2609     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2610     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2611
2612     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2613     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2614     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2615
2616     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2617     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2618     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2619
2620     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2621     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2622     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2623
2624     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2625     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2626     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2627
2628     /* msidbFeatureAttributesFavorSource */
2629     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2630     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2631
2632     /* msidbFeatureAttributesFavorLocal */
2633     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2634     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2635
2636     /* disabled */
2637     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2638     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2639
2640     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2641     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2642     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2643
2644     /* no feature parent:msidbComponentAttributesLocalOnly */
2645     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2646     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2647
2648     /* msidbFeatureAttributesFavorLocal:removed */
2649     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2650     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2651
2652     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2653     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2654     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2655
2656     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2657     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2658     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2659
2660     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2661     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2662     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2663
2664     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2665     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2666     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2667
2668     /* msidbFeatureAttributesFavorSource:removed */
2669     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2670     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2671
2672     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2673     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2674     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2675
2676     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2677     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2678     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2679
2680     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2681     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2682     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2683
2684     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2685     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2686     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2687
2688     /* msidbFeatureAttributesFavorLocal */
2689     r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2690     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2691
2692     r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2693     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2694
2695     /* msidbFeatureAttributesFavorSource */
2696     r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2697     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2698
2699     r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2700     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2701
2702     /* msidbFeatureAttributesFavorAdvertise */
2703     r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2704     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2705
2706     r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2707     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2708
2709     /* msidbFeatureAttributesUIDisallowAbsent */
2710     r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2711     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2712
2713     r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2714     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2715
2716     r = create_feature_components_table( hdb );
2717     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2718
2719     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2720     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2721
2722     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2723     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2724
2725     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2726     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2727
2728     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2729     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2730
2731     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2732     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2733
2734     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2735     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2736
2737     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2738     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2739
2740     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2741     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2742
2743     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2744     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2745
2746     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2747     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2748
2749     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2750     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2751
2752     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2753     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2754
2755     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2756     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2757
2758     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2759     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2760
2761     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2762     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2763
2764     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2765     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2766
2767     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2768     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2769
2770     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2771     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2772
2773     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2774     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2775
2776     r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2777     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2778
2779     r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2780     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2781
2782     r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2783     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2784
2785     r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2786     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2787
2788     r = create_file_table( hdb );
2789     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2790
2791     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2792     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2793
2794     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2795     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2796
2797     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2798     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2799
2800     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2801     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2802
2803     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2804     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2805
2806     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2807     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2808
2809     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2810     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2811
2812     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2813     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2814
2815     /* compressed file */
2816     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2817     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2818
2819     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2820     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2821
2822     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2823     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2824
2825     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2826     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2827
2828     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2829     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2830
2831     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2832     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2833
2834     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2835     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2836
2837     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2838     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2839
2840     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2841     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2842
2843     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2844     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2845
2846     r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2847     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2848
2849     r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2850     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2851
2852     r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2853     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2854
2855     r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
2856     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2857
2858     MsiDatabaseCommit(hdb);
2859
2860     /* these properties must not be in the saved msi file */
2861     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2862     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2863
2864     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2865     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2866
2867     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2868     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2869
2870     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2871     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2872
2873     r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2874     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2875
2876     r = package_from_db( hdb, &hpkg );
2877     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2878     {
2879         skip("Not enough rights to perform tests\n");
2880         DeleteFile(msifile);
2881         return;
2882     }
2883     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2884
2885     MsiCloseHandle(hdb);
2886
2887     CopyFileA(msifile, msifile2, FALSE);
2888     CopyFileA(msifile, msifile3, FALSE);
2889     CopyFileA(msifile, msifile4, FALSE);
2890
2891     state = 0xdeadbee;
2892     action = 0xdeadbee;
2893     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2894     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2895     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2896     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2897
2898     state = 0xdeadbee;
2899     action = 0xdeadbee;
2900     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2901     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2902     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2903     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2904
2905     state = 0xdeadbee;
2906     action = 0xdeadbee;
2907     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2908     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2909     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2910     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2911
2912     state = 0xdeadbee;
2913     action = 0xdeadbee;
2914     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2915     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2916     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2917     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2918
2919     state = 0xdeadbee;
2920     action = 0xdeadbee;
2921     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2922     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2923     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2924     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2925
2926     state = 0xdeadbee;
2927     action = 0xdeadbee;
2928     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2929     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2930     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2931     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2932
2933     state = 0xdeadbee;
2934     action = 0xdeadbee;
2935     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2936     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2937     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2938     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2939
2940     state = 0xdeadbee;
2941     action = 0xdeadbee;
2942     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2943     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2944     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2945     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2946
2947     state = 0xdeadbee;
2948     action = 0xdeadbee;
2949     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2950     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2951     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2952     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2953
2954     state = 0xdeadbee;
2955     action = 0xdeadbee;
2956     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2957     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2958     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2959     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2960
2961     state = 0xdeadbee;
2962     action = 0xdeadbee;
2963     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
2964     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2965     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2966     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2967
2968     state = 0xdeadbee;
2969     action = 0xdeadbee;
2970     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2971     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2972     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2973     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2974
2975     state = 0xdeadbee;
2976     action = 0xdeadbee;
2977     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2978     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2979     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2980     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2981
2982     state = 0xdeadbee;
2983     action = 0xdeadbee;
2984     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2985     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2986     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2987     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2988
2989     state = 0xdeadbee;
2990     action = 0xdeadbee;
2991     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2992     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2993     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2994     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2995
2996     state = 0xdeadbee;
2997     action = 0xdeadbee;
2998     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2999     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3000     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3001     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3002
3003     state = 0xdeadbee;
3004     action = 0xdeadbee;
3005     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3006     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3007     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3008     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3009
3010     state = 0xdeadbee;
3011     action = 0xdeadbee;
3012     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3013     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3014     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3015     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3016
3017     state = 0xdeadbee;
3018     action = 0xdeadbee;
3019     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3020     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3021     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3022     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3023
3024     state = 0xdeadbee;
3025     action = 0xdeadbee;
3026     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3027     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3028     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3029     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3030
3031     state = 0xdeadbee;
3032     action = 0xdeadbee;
3033     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3034     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3035     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3036     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3037
3038     state = 0xdeadbee;
3039     action = 0xdeadbee;
3040     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3041     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3042     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3043     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3044
3045     state = 0xdeadbee;
3046     action = 0xdeadbee;
3047     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3048     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3049     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3050     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3051
3052     state = 0xdeadbee;
3053     action = 0xdeadbee;
3054     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3055     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3056     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3057     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3058
3059     state = 0xdeadbee;
3060     action = 0xdeadbee;
3061     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3062     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3063     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3064     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3065
3066     state = 0xdeadbee;
3067     action = 0xdeadbee;
3068     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3069     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3070     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3071     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3072
3073     state = 0xdeadbee;
3074     action = 0xdeadbee;
3075     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3076     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3077     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3078     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3079
3080     state = 0xdeadbee;
3081     action = 0xdeadbee;
3082     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3083     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3084     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3085     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3086
3087     state = 0xdeadbee;
3088     action = 0xdeadbee;
3089     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3090     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3091     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3092     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3093
3094     state = 0xdeadbee;
3095     action = 0xdeadbee;
3096     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3097     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3098     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3099     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3100
3101     state = 0xdeadbee;
3102     action = 0xdeadbee;
3103     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3104     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3105     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3106     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3107
3108     state = 0xdeadbee;
3109     action = 0xdeadbee;
3110     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3111     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3112     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3113     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3114
3115     state = 0xdeadbee;
3116     action = 0xdeadbee;
3117     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3118     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3119     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3120     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3121
3122     r = MsiDoAction( hpkg, "CostInitialize");
3123     ok( r == ERROR_SUCCESS, "cost init failed\n");
3124
3125     state = 0xdeadbee;
3126     action = 0xdeadbee;
3127     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3129     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3130     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3131
3132     state = 0xdeadbee;
3133     action = 0xdeadbee;
3134     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3136     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3137     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3138
3139     state = 0xdeadbee;
3140     action = 0xdeadbee;
3141     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3143     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3144     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3145
3146     state = 0xdeadbee;
3147     action = 0xdeadbee;
3148     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3150     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3151     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3152
3153     state = 0xdeadbee;
3154     action = 0xdeadbee;
3155     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3157     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3158     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3159
3160     state = 0xdeadbee;
3161     action = 0xdeadbee;
3162     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3164     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3165     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3166
3167     state = 0xdeadbee;
3168     action = 0xdeadbee;
3169     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3171     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3172     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3173
3174     state = 0xdeadbee;
3175     action = 0xdeadbee;
3176     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3177     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3178     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3179     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3180
3181     state = 0xdeadbee;
3182     action = 0xdeadbee;
3183     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3184     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3185     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3186     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3187
3188     state = 0xdeadbee;
3189     action = 0xdeadbee;
3190     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3191     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3192     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3193     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3194
3195     state = 0xdeadbee;
3196     action = 0xdeadbee;
3197     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3198     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3199     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3200     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3201
3202     state = 0xdeadbee;
3203     action = 0xdeadbee;
3204     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3205     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3206     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3207     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3208
3209     state = 0xdeadbee;
3210     action = 0xdeadbee;
3211     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3212     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3213     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3214     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3215
3216     state = 0xdeadbee;
3217     action = 0xdeadbee;
3218     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3219     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3220     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3221     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3222
3223     state = 0xdeadbee;
3224     action = 0xdeadbee;
3225     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3226     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3227     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3228     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3229
3230     state = 0xdeadbee;
3231     action = 0xdeadbee;
3232     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3233     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3234     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3235     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3236
3237     state = 0xdeadbee;
3238     action = 0xdeadbee;
3239     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3240     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3241     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3242     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3243
3244     state = 0xdeadbee;
3245     action = 0xdeadbee;
3246     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3247     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3248     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3249     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3250
3251     state = 0xdeadbee;
3252     action = 0xdeadbee;
3253     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3254     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3255     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3256     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3257
3258     state = 0xdeadbee;
3259     action = 0xdeadbee;
3260     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3261     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3262     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3263     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3264
3265     state = 0xdeadbee;
3266     action = 0xdeadbee;
3267     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3268     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3269     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3270     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3271
3272     state = 0xdeadbee;
3273     action = 0xdeadbee;
3274     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3275     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3276     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3277     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3278
3279     state = 0xdeadbee;
3280     action = 0xdeadbee;
3281     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3282     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3283     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3284     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3285
3286     state = 0xdeadbee;
3287     action = 0xdeadbee;
3288     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3289     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3290     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3291     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3292
3293     state = 0xdeadbee;
3294     action = 0xdeadbee;
3295     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3296     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3297     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3298     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3299
3300     state = 0xdeadbee;
3301     action = 0xdeadbee;
3302     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3303     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3304     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3305     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3306
3307     state = 0xdeadbee;
3308     action = 0xdeadbee;
3309     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3310     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3311     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3312     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3313
3314     state = 0xdeadbee;
3315     action = 0xdeadbee;
3316     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3317     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3318     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3319     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3320
3321     state = 0xdeadbee;
3322     action = 0xdeadbee;
3323     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3324     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3325     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3326     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3327
3328     state = 0xdeadbee;
3329     action = 0xdeadbee;
3330     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3331     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3332     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3333     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3334
3335     state = 0xdeadbee;
3336     action = 0xdeadbee;
3337     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3338     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3339     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3340     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3341
3342     state = 0xdeadbee;
3343     action = 0xdeadbee;
3344     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3345     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3346     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3347     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3348
3349     state = 0xdeadbee;
3350     action = 0xdeadbee;
3351     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3352     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3353     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3354     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3355
3356     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3357
3358     r = MsiDoAction( hpkg, "FileCost");
3359     ok( r == ERROR_SUCCESS, "file cost failed\n");
3360
3361     r = MsiGetFeatureState(hpkg, "one", NULL, NULL);
3362     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3363
3364     action = 0xdeadbee;
3365     r = MsiGetFeatureState(hpkg, "one", NULL, &action);
3366     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3367     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3368
3369     state = 0xdeadbee;
3370     r = MsiGetFeatureState( hpkg, "one", &state, NULL);
3371     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3372     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3373
3374     state = 0xdeadbee;
3375     action = 0xdeadbee;
3376     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3377     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3378     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3379     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3380
3381     state = 0xdeadbee;
3382     action = 0xdeadbee;
3383     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3384     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3385     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3386     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3387
3388     state = 0xdeadbee;
3389     action = 0xdeadbee;
3390     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3391     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3392     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3393     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3394
3395     state = 0xdeadbee;
3396     action = 0xdeadbee;
3397     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3398     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3399     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3400     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3401
3402     state = 0xdeadbee;
3403     action = 0xdeadbee;
3404     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3405     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3406     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3407     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3408
3409     state = 0xdeadbee;
3410     action = 0xdeadbee;
3411     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3412     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3413     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3414     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3415
3416     state = 0xdeadbee;
3417     action = 0xdeadbee;
3418     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3419     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3420     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3421     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3422
3423     state = 0xdeadbee;
3424     action = 0xdeadbee;
3425     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3426     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3427     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3428     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3429
3430     state = 0xdeadbee;
3431     action = 0xdeadbee;
3432     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3433     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3434     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3435     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3436
3437     state = 0xdeadbee;
3438     action = 0xdeadbee;
3439     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3440     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3441     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3442     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3443
3444     state = 0xdeadbee;
3445     action = 0xdeadbee;
3446     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3448     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3449     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3450
3451     state = 0xdeadbee;
3452     action = 0xdeadbee;
3453     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3455     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3456     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3457
3458     state = 0xdeadbee;
3459     action = 0xdeadbee;
3460     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3461     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3462     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3463     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3464
3465     state = 0xdeadbee;
3466     action = 0xdeadbee;
3467     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3468     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3469     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3470     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3471
3472     state = 0xdeadbee;
3473     action = 0xdeadbee;
3474     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3475     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3476     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3477     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3478
3479     state = 0xdeadbee;
3480     action = 0xdeadbee;
3481     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3482     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3483     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3484     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3485
3486     state = 0xdeadbee;
3487     action = 0xdeadbee;
3488     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3489     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3490     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3491     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3492
3493     state = 0xdeadbee;
3494     action = 0xdeadbee;
3495     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3496     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3497     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3498     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3499
3500     state = 0xdeadbee;
3501     action = 0xdeadbee;
3502     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3503     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3504     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3505     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3506
3507     state = 0xdeadbee;
3508     action = 0xdeadbee;
3509     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3510     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3511     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3512     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3513
3514     state = 0xdeadbee;
3515     action = 0xdeadbee;
3516     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3517     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3518     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3519     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3520
3521     state = 0xdeadbee;
3522     action = 0xdeadbee;
3523     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3524     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3525     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3526     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3527
3528     state = 0xdeadbee;
3529     action = 0xdeadbee;
3530     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3531     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3532     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3533     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3534
3535     state = 0xdeadbee;
3536     action = 0xdeadbee;
3537     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3538     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3539     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3540     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3541
3542     state = 0xdeadbee;
3543     action = 0xdeadbee;
3544     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3545     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3546     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3547     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3548
3549     state = 0xdeadbee;
3550     action = 0xdeadbee;
3551     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3552     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3553     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3554     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3555
3556     state = 0xdeadbee;
3557     action = 0xdeadbee;
3558     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3559     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3560     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3561     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3562
3563     state = 0xdeadbee;
3564     action = 0xdeadbee;
3565     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3566     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3567     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3568     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3569
3570     state = 0xdeadbee;
3571     action = 0xdeadbee;
3572     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3573     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3574     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3575     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3576
3577     state = 0xdeadbee;
3578     action = 0xdeadbee;
3579     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3580     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3581     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3582     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3583
3584     state = 0xdeadbee;
3585     action = 0xdeadbee;
3586     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3587     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3588     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3589     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3590
3591     state = 0xdeadbee;
3592     action = 0xdeadbee;
3593     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3594     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3595     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3596     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3597
3598     state = 0xdeadbee;
3599     action = 0xdeadbee;
3600     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3601     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3602     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3603     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3604
3605     r = MsiDoAction( hpkg, "CostFinalize");
3606     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3607
3608     state = 0xdeadbee;
3609     action = 0xdeadbee;
3610     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3611     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3612     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3613     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3614
3615     state = 0xdeadbee;
3616     action = 0xdeadbee;
3617     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3618     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3619     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3620     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3621
3622     state = 0xdeadbee;
3623     action = 0xdeadbee;
3624     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3625     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3626     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3627     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3628
3629     state = 0xdeadbee;
3630     action = 0xdeadbee;
3631     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3632     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3633     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3634     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3635
3636     state = 0xdeadbee;
3637     action = 0xdeadbee;
3638     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3639     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3640     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3641     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3642
3643     state = 0xdeadbee;
3644     action = 0xdeadbee;
3645     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3646     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3647     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3648     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3649
3650     state = 0xdeadbee;
3651     action = 0xdeadbee;
3652     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3653     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3654     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3655     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3656
3657     state = 0xdeadbee;
3658     action = 0xdeadbee;
3659     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3660     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3661     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3662     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3663
3664     state = 0xdeadbee;
3665     action = 0xdeadbee;
3666     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3667     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3668     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3669     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3670
3671     state = 0xdeadbee;
3672     action = 0xdeadbee;
3673     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3674     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3675     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3676     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3677
3678     state = 0xdeadbee;
3679     action = 0xdeadbee;
3680     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3681     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3682     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3683     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3684
3685     state = 0xdeadbee;
3686     action = 0xdeadbee;
3687     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3688     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3689     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3690     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3691
3692     state = 0xdeadbee;
3693     action = 0xdeadbee;
3694     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3695     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3696     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3697     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3698
3699     state = 0xdeadbee;
3700     action = 0xdeadbee;
3701     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3702     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3703     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3704     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3705
3706     state = 0xdeadbee;
3707     action = 0xdeadbee;
3708     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3709     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3710     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3711     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3712
3713     state = 0xdeadbee;
3714     action = 0xdeadbee;
3715     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3716     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3717     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3718     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3719
3720     state = 0xdeadbee;
3721     action = 0xdeadbee;
3722     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3723     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3724     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3725     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3726
3727     state = 0xdeadbee;
3728     action = 0xdeadbee;
3729     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3730     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3731     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3732     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3733
3734     state = 0xdeadbee;
3735     action = 0xdeadbee;
3736     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3737     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3738     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3739     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3740
3741     state = 0xdeadbee;
3742     action = 0xdeadbee;
3743     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3744     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3745     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3746     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3747
3748     state = 0xdeadbee;
3749     action = 0xdeadbee;
3750     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3751     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3752     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3753     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3754
3755     state = 0xdeadbee;
3756     action = 0xdeadbee;
3757     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3758     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3759     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3760     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3761
3762     state = 0xdeadbee;
3763     action = 0xdeadbee;
3764     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3765     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3766     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3767     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3768
3769     state = 0xdeadbee;
3770     action = 0xdeadbee;
3771     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3772     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3773     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3774     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3775
3776     state = 0xdeadbee;
3777     action = 0xdeadbee;
3778     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3779     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3780     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3781     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3782
3783     state = 0xdeadbee;
3784     action = 0xdeadbee;
3785     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3786     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3787     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3788     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3789
3790     state = 0xdeadbee;
3791     action = 0xdeadbee;
3792     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3793     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3794     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3795     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3796
3797     state = 0xdeadbee;
3798     action = 0xdeadbee;
3799     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3800     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3801     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3802     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3803
3804     state = 0xdeadbee;
3805     action = 0xdeadbee;
3806     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3807     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3808     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3809     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3810
3811     state = 0xdeadbee;
3812     action = 0xdeadbee;
3813     r = MsiGetComponentState(hpkg, "tau", &state, &action);
3814     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3815     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3816     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3817
3818     state = 0xdeadbee;
3819     action = 0xdeadbee;
3820     r = MsiGetComponentState(hpkg, "phi", &state, &action);
3821     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3822     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3823     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3824
3825     state = 0xdeadbee;
3826     action = 0xdeadbee;
3827     r = MsiGetComponentState(hpkg, "chi", &state, &action);
3828     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3829     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3830     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3831
3832     state = 0xdeadbee;
3833     action = 0xdeadbee;
3834     r = MsiGetComponentState(hpkg, "psi", &state, &action);
3835     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3836     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3837     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3838
3839     MsiCloseHandle( hpkg );
3840
3841     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3842
3843     /* publish the features and components */
3844     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3845     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3846
3847     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3848     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3849
3850     /* these properties must not be in the saved msi file */
3851     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3852     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3853
3854     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3855     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3856
3857     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3858     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3859
3860     r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3861     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3862
3863     r = package_from_db( hdb, &hpkg );
3864     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3865
3866     MsiCloseHandle(hdb);
3867
3868     state = 0xdeadbee;
3869     action = 0xdeadbee;
3870     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3871     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3872     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3873     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3874
3875     state = 0xdeadbee;
3876     action = 0xdeadbee;
3877     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3878     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3879     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3880     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3881
3882     state = 0xdeadbee;
3883     action = 0xdeadbee;
3884     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3885     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3886     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3887     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3888
3889     state = 0xdeadbee;
3890     action = 0xdeadbee;
3891     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3892     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3893     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3894     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3895
3896     state = 0xdeadbee;
3897     action = 0xdeadbee;
3898     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3899     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3900     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3901     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3902
3903     state = 0xdeadbee;
3904     action = 0xdeadbee;
3905     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3906     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3907     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3908     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3909
3910     state = 0xdeadbee;
3911     action = 0xdeadbee;
3912     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3913     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3914     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3915     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3916
3917     state = 0xdeadbee;
3918     action = 0xdeadbee;
3919     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
3920     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3921     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3922     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3923
3924     state = 0xdeadbee;
3925     action = 0xdeadbee;
3926     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
3927     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3928     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3929     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3930
3931     state = 0xdeadbee;
3932     action = 0xdeadbee;
3933     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
3934     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3935     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3936     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3937
3938     state = 0xdeadbee;
3939     action = 0xdeadbee;
3940     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
3941     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3942     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3943     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3944
3945     state = 0xdeadbee;
3946     action = 0xdeadbee;
3947     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3948     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3949     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3950     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3951
3952     state = 0xdeadbee;
3953     action = 0xdeadbee;
3954     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3955     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3956     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3957     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3958
3959     state = 0xdeadbee;
3960     action = 0xdeadbee;
3961     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3962     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3963     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3964     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3965
3966     state = 0xdeadbee;
3967     action = 0xdeadbee;
3968     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3969     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3970     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3971     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3972
3973     state = 0xdeadbee;
3974     action = 0xdeadbee;
3975     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3976     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3977     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3978     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3979
3980     state = 0xdeadbee;
3981     action = 0xdeadbee;
3982     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3983     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3984     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3985     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3986
3987     state = 0xdeadbee;
3988     action = 0xdeadbee;
3989     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3990     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3991     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3992     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3993
3994     state = 0xdeadbee;
3995     action = 0xdeadbee;
3996     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3997     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3998     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3999     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4000
4001     state = 0xdeadbee;
4002     action = 0xdeadbee;
4003     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4004     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4005     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4006     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4007
4008     state = 0xdeadbee;
4009     action = 0xdeadbee;
4010     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4011     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4012     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4013     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4014
4015     state = 0xdeadbee;
4016     action = 0xdeadbee;
4017     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4018     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4019     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4020     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4021
4022     state = 0xdeadbee;
4023     action = 0xdeadbee;
4024     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4025     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4026     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4027     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4028
4029     state = 0xdeadbee;
4030     action = 0xdeadbee;
4031     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4032     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4033     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4034     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4035
4036     state = 0xdeadbee;
4037     action = 0xdeadbee;
4038     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4039     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4040     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4041     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4042
4043     state = 0xdeadbee;
4044     action = 0xdeadbee;
4045     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4046     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4047     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4048     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4049
4050     state = 0xdeadbee;
4051     action = 0xdeadbee;
4052     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4053     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4054     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4055     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4056
4057     state = 0xdeadbee;
4058     action = 0xdeadbee;
4059     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4060     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4061     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4062     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4063
4064     state = 0xdeadbee;
4065     action = 0xdeadbee;
4066     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4067     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4068     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4069     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4070
4071     state = 0xdeadbee;
4072     action = 0xdeadbee;
4073     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4074     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4075     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4076     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4077
4078     state = 0xdeadbee;
4079     action = 0xdeadbee;
4080     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4081     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4082     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4083     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4084
4085     state = 0xdeadbee;
4086     action = 0xdeadbee;
4087     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4088     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4089     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4090     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4091
4092     state = 0xdeadbee;
4093     action = 0xdeadbee;
4094     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4095     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4096     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4097     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4098
4099     r = MsiDoAction( hpkg, "CostInitialize");
4100     ok( r == ERROR_SUCCESS, "cost init failed\n");
4101
4102     state = 0xdeadbee;
4103     action = 0xdeadbee;
4104     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4108
4109     state = 0xdeadbee;
4110     action = 0xdeadbee;
4111     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4115
4116     state = 0xdeadbee;
4117     action = 0xdeadbee;
4118     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4122
4123     state = 0xdeadbee;
4124     action = 0xdeadbee;
4125     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4126     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4127     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4128     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4129
4130     state = 0xdeadbee;
4131     action = 0xdeadbee;
4132     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4134     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4135     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4136
4137     state = 0xdeadbee;
4138     action = 0xdeadbee;
4139     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4140     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4141     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4142     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4143
4144     state = 0xdeadbee;
4145     action = 0xdeadbee;
4146     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4147     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4148     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4149     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4150
4151     state = 0xdeadbee;
4152     action = 0xdeadbee;
4153     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4154     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4155     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4156     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4157
4158     state = 0xdeadbee;
4159     action = 0xdeadbee;
4160     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4164
4165     state = 0xdeadbee;
4166     action = 0xdeadbee;
4167     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4171
4172     state = 0xdeadbee;
4173     action = 0xdeadbee;
4174     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4176     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4177     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4178
4179     state = 0xdeadbee;
4180     action = 0xdeadbee;
4181     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4182     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4183     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4184     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4185
4186     state = 0xdeadbee;
4187     action = 0xdeadbee;
4188     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4189     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4190     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4191     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4192
4193     state = 0xdeadbee;
4194     action = 0xdeadbee;
4195     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4196     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4197     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4198     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4199
4200     state = 0xdeadbee;
4201     action = 0xdeadbee;
4202     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4203     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4204     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4205     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4206
4207     state = 0xdeadbee;
4208     action = 0xdeadbee;
4209     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4210     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4211     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4212     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4213
4214     state = 0xdeadbee;
4215     action = 0xdeadbee;
4216     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4217     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4218     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4219     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4220
4221     state = 0xdeadbee;
4222     action = 0xdeadbee;
4223     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4224     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4225     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4226     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4227
4228     state = 0xdeadbee;
4229     action = 0xdeadbee;
4230     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4232     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4233     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4234
4235     state = 0xdeadbee;
4236     action = 0xdeadbee;
4237     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4239     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4240     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4241
4242     state = 0xdeadbee;
4243     action = 0xdeadbee;
4244     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4246     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4247     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4248
4249     state = 0xdeadbee;
4250     action = 0xdeadbee;
4251     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4252     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4253     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4254     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4255
4256     state = 0xdeadbee;
4257     action = 0xdeadbee;
4258     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4259     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4260     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4261     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4262
4263     state = 0xdeadbee;
4264     action = 0xdeadbee;
4265     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4266     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4267     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4268     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4269
4270     state = 0xdeadbee;
4271     action = 0xdeadbee;
4272     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4273     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4274     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4275     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4276
4277     state = 0xdeadbee;
4278     action = 0xdeadbee;
4279     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4280     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4281     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4282     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4283
4284     state = 0xdeadbee;
4285     action = 0xdeadbee;
4286     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4287     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4288     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4289     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4290
4291     state = 0xdeadbee;
4292     action = 0xdeadbee;
4293     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4294     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4295     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4296     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4297
4298     state = 0xdeadbee;
4299     action = 0xdeadbee;
4300     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4301     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4302     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4303     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4304
4305     state = 0xdeadbee;
4306     action = 0xdeadbee;
4307     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4308     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4309     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4310     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4311
4312     state = 0xdeadbee;
4313     action = 0xdeadbee;
4314     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4315     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4316     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4317     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4318
4319     state = 0xdeadbee;
4320     action = 0xdeadbee;
4321     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4322     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4323     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4324     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4325
4326     state = 0xdeadbee;
4327     action = 0xdeadbee;
4328     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4329     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4330     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4331     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4332
4333     r = MsiDoAction( hpkg, "FileCost");
4334     ok( r == ERROR_SUCCESS, "file cost failed\n");
4335
4336     state = 0xdeadbee;
4337     action = 0xdeadbee;
4338     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4340     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4341     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4342
4343     state = 0xdeadbee;
4344     action = 0xdeadbee;
4345     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4347     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4348     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4349
4350     state = 0xdeadbee;
4351     action = 0xdeadbee;
4352     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4354     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4355     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4356
4357     state = 0xdeadbee;
4358     action = 0xdeadbee;
4359     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4361     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4362     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4363
4364     state = 0xdeadbee;
4365     action = 0xdeadbee;
4366     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4368     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4369     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4370
4371     state = 0xdeadbee;
4372     action = 0xdeadbee;
4373     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4375     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4376     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4377
4378     state = 0xdeadbee;
4379     action = 0xdeadbee;
4380     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4382     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4383     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4384
4385     state = 0xdeadbee;
4386     action = 0xdeadbee;
4387     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4388     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4389     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4390     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4391
4392     state = 0xdeadbee;
4393     action = 0xdeadbee;
4394     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4396     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4397     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4398
4399     state = 0xdeadbee;
4400     action = 0xdeadbee;
4401     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4402     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4403     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4404     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4405
4406     state = 0xdeadbee;
4407     action = 0xdeadbee;
4408     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4409     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4410     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4411     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4412
4413     state = 0xdeadbee;
4414     action = 0xdeadbee;
4415     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4416     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4417     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4418     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4419
4420     state = 0xdeadbee;
4421     action = 0xdeadbee;
4422     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4423     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4424     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4425     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4426
4427     state = 0xdeadbee;
4428     action = 0xdeadbee;
4429     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4430     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4431     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4432     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4433
4434     state = 0xdeadbee;
4435     action = 0xdeadbee;
4436     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4437     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4438     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4439     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4440
4441     state = 0xdeadbee;
4442     action = 0xdeadbee;
4443     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4444     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4445     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4446     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4447
4448     state = 0xdeadbee;
4449     action = 0xdeadbee;
4450     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4451     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4452     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4453     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4454
4455     state = 0xdeadbee;
4456     action = 0xdeadbee;
4457     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4458     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4459     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4460     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4461
4462     state = 0xdeadbee;
4463     action = 0xdeadbee;
4464     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4465     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4466     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4467     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4468
4469     state = 0xdeadbee;
4470     action = 0xdeadbee;
4471     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4472     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4473     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4474     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4475
4476     state = 0xdeadbee;
4477     action = 0xdeadbee;
4478     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4479     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4480     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4481     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4482
4483     state = 0xdeadbee;
4484     action = 0xdeadbee;
4485     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4486     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4487     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4488     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4489
4490     state = 0xdeadbee;
4491     action = 0xdeadbee;
4492     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4493     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4494     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4495     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4496
4497     state = 0xdeadbee;
4498     action = 0xdeadbee;
4499     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4500     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4501     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4502     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4503
4504     state = 0xdeadbee;
4505     action = 0xdeadbee;
4506     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4507     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4508     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4509     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4510
4511     state = 0xdeadbee;
4512     action = 0xdeadbee;
4513     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4514     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4515     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4516     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4517
4518     state = 0xdeadbee;
4519     action = 0xdeadbee;
4520     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4521     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4522     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4523     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4524
4525     state = 0xdeadbee;
4526     action = 0xdeadbee;
4527     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4528     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4529     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4530     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4531
4532     state = 0xdeadbee;
4533     action = 0xdeadbee;
4534     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4535     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4536     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4537     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4538
4539     state = 0xdeadbee;
4540     action = 0xdeadbee;
4541     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4542     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4543     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4544     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4545
4546     state = 0xdeadbee;
4547     action = 0xdeadbee;
4548     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4549     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4550     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4551     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4552
4553     r = MsiDoAction( hpkg, "CostFinalize");
4554     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4555
4556     state = 0xdeadbee;
4557     action = 0xdeadbee;
4558     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4559     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4560     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4561     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4562
4563     state = 0xdeadbee;
4564     action = 0xdeadbee;
4565     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4566     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4567     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4568     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4569
4570     state = 0xdeadbee;
4571     action = 0xdeadbee;
4572     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4573     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4574     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4575     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4576
4577     state = 0xdeadbee;
4578     action = 0xdeadbee;
4579     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4580     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4581     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4582     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4583
4584     state = 0xdeadbee;
4585     action = 0xdeadbee;
4586     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4587     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4588     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4589     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4590
4591     state = 0xdeadbee;
4592     action = 0xdeadbee;
4593     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4594     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4595     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4596     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4597
4598     state = 0xdeadbee;
4599     action = 0xdeadbee;
4600     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4601     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4602     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4603     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4604
4605     state = 0xdeadbee;
4606     action = 0xdeadbee;
4607     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4608     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4609     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4610     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4611
4612     state = 0xdeadbee;
4613     action = 0xdeadbee;
4614     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4615     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4616     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4617     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4618
4619     state = 0xdeadbee;
4620     action = 0xdeadbee;
4621     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4622     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4623     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4624     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4625
4626     state = 0xdeadbee;
4627     action = 0xdeadbee;
4628     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4629     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4630     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4631     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4632
4633     state = 0xdeadbee;
4634     action = 0xdeadbee;
4635     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4636     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4637     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4638     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4639
4640     state = 0xdeadbee;
4641     action = 0xdeadbee;
4642     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4643     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4644     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4645     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4646
4647     state = 0xdeadbee;
4648     action = 0xdeadbee;
4649     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4650     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4651     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4652     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4653
4654     state = 0xdeadbee;
4655     action = 0xdeadbee;
4656     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4657     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4658     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4659     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4660
4661     state = 0xdeadbee;
4662     action = 0xdeadbee;
4663     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4664     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4665     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4666     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4667
4668     state = 0xdeadbee;
4669     action = 0xdeadbee;
4670     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4671     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4672     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4673     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4674
4675     state = 0xdeadbee;
4676     action = 0xdeadbee;
4677     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4678     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4679     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4680     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4681
4682     state = 0xdeadbee;
4683     action = 0xdeadbee;
4684     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4685     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4686     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4687     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4688
4689     state = 0xdeadbee;
4690     action = 0xdeadbee;
4691     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4692     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4693     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4694     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4695
4696     state = 0xdeadbee;
4697     action = 0xdeadbee;
4698     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4699     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4700     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4701     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4702
4703     state = 0xdeadbee;
4704     action = 0xdeadbee;
4705     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4706     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4707     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4708     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4709
4710     state = 0xdeadbee;
4711     action = 0xdeadbee;
4712     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4713     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4714     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4715     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4716
4717     state = 0xdeadbee;
4718     action = 0xdeadbee;
4719     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4720     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4721     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4722     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4723
4724     state = 0xdeadbee;
4725     action = 0xdeadbee;
4726     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4727     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4728     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4729     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4730
4731     state = 0xdeadbee;
4732     action = 0xdeadbee;
4733     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4734     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4735     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4736     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4737
4738     state = 0xdeadbee;
4739     action = 0xdeadbee;
4740     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4741     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4742     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4743     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4744
4745     state = 0xdeadbee;
4746     action = 0xdeadbee;
4747     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4748     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4749     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4750     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4751
4752     state = 0xdeadbee;
4753     action = 0xdeadbee;
4754     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4755     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4756     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4757     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4758
4759     state = 0xdeadbee;
4760     action = 0xdeadbee;
4761     r = MsiGetComponentState(hpkg, "tau", &state, &action);
4762     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4763     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4764     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4765
4766     state = 0xdeadbee;
4767     action = 0xdeadbee;
4768     r = MsiGetComponentState(hpkg, "phi", &state, &action);
4769     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4770     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4771     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4772
4773     state = 0xdeadbee;
4774     action = 0xdeadbee;
4775     r = MsiGetComponentState(hpkg, "chi", &state, &action);
4776     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4777     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4778     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4779
4780     state = 0xdeadbee;
4781     action = 0xdeadbee;
4782     r = MsiGetComponentState(hpkg, "psi", &state, &action);
4783     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4784     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4785     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4786
4787     MsiCloseHandle(hpkg);
4788
4789     /* uninstall the product */
4790     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4791     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4792
4793     /* all features installed locally */
4794     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4796
4797     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4798     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4799
4800     /* these properties must not be in the saved msi file */
4801     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
4802     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4803
4804     r = package_from_db( hdb, &hpkg );
4805     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
4806
4807     state = 0xdeadbee;
4808     action = 0xdeadbee;
4809     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4810     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4811     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4812     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4813
4814     state = 0xdeadbee;
4815     action = 0xdeadbee;
4816     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4817     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4818     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4819     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4820
4821     state = 0xdeadbee;
4822     action = 0xdeadbee;
4823     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4824     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4825     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4826     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4827
4828     state = 0xdeadbee;
4829     action = 0xdeadbee;
4830     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4831     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4832     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4833     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4834
4835     state = 0xdeadbee;
4836     action = 0xdeadbee;
4837     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4838     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4839     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4840     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4841
4842     state = 0xdeadbee;
4843     action = 0xdeadbee;
4844     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4845     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4846     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4847     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4848
4849     state = 0xdeadbee;
4850     action = 0xdeadbee;
4851     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4852     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4853     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4854     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4855
4856     state = 0xdeadbee;
4857     action = 0xdeadbee;
4858     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
4859     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4860     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4861     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4862
4863     state = 0xdeadbee;
4864     action = 0xdeadbee;
4865     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
4866     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4867     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4868     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4869
4870     state = 0xdeadbee;
4871     action = 0xdeadbee;
4872     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
4873     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4874     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4875     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4876
4877     state = 0xdeadbee;
4878     action = 0xdeadbee;
4879     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
4880     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4881     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4882     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4883
4884     state = 0xdeadbee;
4885     action = 0xdeadbee;
4886     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4887     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4888     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4889     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4890
4891     state = 0xdeadbee;
4892     action = 0xdeadbee;
4893     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4894     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4895     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4896     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4897
4898     state = 0xdeadbee;
4899     action = 0xdeadbee;
4900     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4901     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4902     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4903     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4904
4905     state = 0xdeadbee;
4906     action = 0xdeadbee;
4907     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4908     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4909     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4910     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4911
4912     state = 0xdeadbee;
4913     action = 0xdeadbee;
4914     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4915     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4916     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4917     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4918
4919     state = 0xdeadbee;
4920     action = 0xdeadbee;
4921     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4922     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4923     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4924     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4925
4926     state = 0xdeadbee;
4927     action = 0xdeadbee;
4928     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4929     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4930     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4931     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4932
4933     state = 0xdeadbee;
4934     action = 0xdeadbee;
4935     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4936     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4937     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4938     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4939
4940     state = 0xdeadbee;
4941     action = 0xdeadbee;
4942     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4943     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4944     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4945     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4946
4947     state = 0xdeadbee;
4948     action = 0xdeadbee;
4949     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4950     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4951     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4952     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4953
4954     state = 0xdeadbee;
4955     action = 0xdeadbee;
4956     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4957     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4958     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4959     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4960
4961     state = 0xdeadbee;
4962     action = 0xdeadbee;
4963     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4964     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4965     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4966     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4967
4968     state = 0xdeadbee;
4969     action = 0xdeadbee;
4970     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4971     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4972     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4973     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4974
4975     state = 0xdeadbee;
4976     action = 0xdeadbee;
4977     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4978     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4979     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4980     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4981
4982     state = 0xdeadbee;
4983     action = 0xdeadbee;
4984     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4985     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4986     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4987     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4988
4989     state = 0xdeadbee;
4990     action = 0xdeadbee;
4991     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4992     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4993     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4994     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4995
4996     state = 0xdeadbee;
4997     action = 0xdeadbee;
4998     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4999     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5000     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5001     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5002
5003     state = 0xdeadbee;
5004     action = 0xdeadbee;
5005     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5006     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5007     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5008     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5009
5010     state = 0xdeadbee;
5011     action = 0xdeadbee;
5012     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5013     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5014     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5015     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5016
5017     state = 0xdeadbee;
5018     action = 0xdeadbee;
5019     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5020     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5021     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5022     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5023
5024     state = 0xdeadbee;
5025     action = 0xdeadbee;
5026     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5027     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5028     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5029     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5030
5031     state = 0xdeadbee;
5032     action = 0xdeadbee;
5033     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5034     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5035     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5036     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5037
5038     r = MsiDoAction( hpkg, "CostInitialize");
5039     ok( r == ERROR_SUCCESS, "cost init failed\n");
5040
5041     state = 0xdeadbee;
5042     action = 0xdeadbee;
5043     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5045     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5046     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5047
5048     state = 0xdeadbee;
5049     action = 0xdeadbee;
5050     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5052     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5053     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5054
5055     state = 0xdeadbee;
5056     action = 0xdeadbee;
5057     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5059     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5060     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5061
5062     state = 0xdeadbee;
5063     action = 0xdeadbee;
5064     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5066     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5067     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5068
5069     state = 0xdeadbee;
5070     action = 0xdeadbee;
5071     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5072     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5073     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5074     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5075
5076     state = 0xdeadbee;
5077     action = 0xdeadbee;
5078     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5079     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5080     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5081     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5082
5083     state = 0xdeadbee;
5084     action = 0xdeadbee;
5085     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5086     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5087     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5088     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5089
5090     state = 0xdeadbee;
5091     action = 0xdeadbee;
5092     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5093     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5094     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5095     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5096
5097     state = 0xdeadbee;
5098     action = 0xdeadbee;
5099     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5101     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5102     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5103
5104     state = 0xdeadbee;
5105     action = 0xdeadbee;
5106     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5108     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5109     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5110
5111     state = 0xdeadbee;
5112     action = 0xdeadbee;
5113     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5115     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5116     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5117
5118     state = 0xdeadbee;
5119     action = 0xdeadbee;
5120     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5122     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5123     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5124
5125     state = 0xdeadbee;
5126     action = 0xdeadbee;
5127     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5129     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5130     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5131
5132     state = 0xdeadbee;
5133     action = 0xdeadbee;
5134     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5136     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5137     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5138
5139     state = 0xdeadbee;
5140     action = 0xdeadbee;
5141     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5143     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5144     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5145
5146     state = 0xdeadbee;
5147     action = 0xdeadbee;
5148     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5150     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5151     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5152
5153     state = 0xdeadbee;
5154     action = 0xdeadbee;
5155     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5157     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5158     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5159
5160     state = 0xdeadbee;
5161     action = 0xdeadbee;
5162     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5164     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5165     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5166
5167     state = 0xdeadbee;
5168     action = 0xdeadbee;
5169     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5171     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5172     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5173
5174     state = 0xdeadbee;
5175     action = 0xdeadbee;
5176     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5177     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5178     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5179     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5180
5181     state = 0xdeadbee;
5182     action = 0xdeadbee;
5183     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5184     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5185     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5186     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5187
5188     state = 0xdeadbee;
5189     action = 0xdeadbee;
5190     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5191     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5192     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5193     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5194
5195     state = 0xdeadbee;
5196     action = 0xdeadbee;
5197     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5198     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5199     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5200     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5201
5202     state = 0xdeadbee;
5203     action = 0xdeadbee;
5204     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5205     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5206     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5207     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5208
5209     state = 0xdeadbee;
5210     action = 0xdeadbee;
5211     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5212     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5213     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5214     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5215
5216     state = 0xdeadbee;
5217     action = 0xdeadbee;
5218     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5219     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5220     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5221     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5222
5223     state = 0xdeadbee;
5224     action = 0xdeadbee;
5225     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5226     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5227     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5228     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5229
5230     state = 0xdeadbee;
5231     action = 0xdeadbee;
5232     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5233     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5234     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5235     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5236
5237     state = 0xdeadbee;
5238     action = 0xdeadbee;
5239     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5240     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5241     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5242     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5243
5244     state = 0xdeadbee;
5245     action = 0xdeadbee;
5246     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5247     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5248     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5249     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5250
5251     state = 0xdeadbee;
5252     action = 0xdeadbee;
5253     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5254     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5255     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5256     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5257
5258     state = 0xdeadbee;
5259     action = 0xdeadbee;
5260     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5261     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5262     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5263     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5264
5265     state = 0xdeadbee;
5266     action = 0xdeadbee;
5267     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5268     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5269     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5270     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5271
5272     r = MsiDoAction( hpkg, "FileCost");
5273     ok( r == ERROR_SUCCESS, "file cost failed\n");
5274
5275     state = 0xdeadbee;
5276     action = 0xdeadbee;
5277     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5278     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5279     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5280     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5281
5282     state = 0xdeadbee;
5283     action = 0xdeadbee;
5284     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5285     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5286     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5287     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5288
5289     state = 0xdeadbee;
5290     action = 0xdeadbee;
5291     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5292     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5293     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5294     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5295
5296     state = 0xdeadbee;
5297     action = 0xdeadbee;
5298     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5299     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5300     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5301     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5302
5303     state = 0xdeadbee;
5304     action = 0xdeadbee;
5305     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5306     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5307     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5308     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5309
5310     state = 0xdeadbee;
5311     action = 0xdeadbee;
5312     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5313     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5314     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5315     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5316
5317     state = 0xdeadbee;
5318     action = 0xdeadbee;
5319     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5320     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5321     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5322     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5323
5324     state = 0xdeadbee;
5325     action = 0xdeadbee;
5326     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5327     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5328     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5329     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5330
5331     state = 0xdeadbee;
5332     action = 0xdeadbee;
5333     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5334     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5335     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5336     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5337
5338     state = 0xdeadbee;
5339     action = 0xdeadbee;
5340     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5341     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5342     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5343     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5344
5345     state = 0xdeadbee;
5346     action = 0xdeadbee;
5347     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5348     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5349     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5350     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5351
5352     state = 0xdeadbee;
5353     action = 0xdeadbee;
5354     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5355     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5356     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5357     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5358
5359     state = 0xdeadbee;
5360     action = 0xdeadbee;
5361     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5362     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5363     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5364     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5365
5366     state = 0xdeadbee;
5367     action = 0xdeadbee;
5368     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5369     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5370     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5371     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5372
5373     state = 0xdeadbee;
5374     action = 0xdeadbee;
5375     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5376     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5377     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5378     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5379
5380     state = 0xdeadbee;
5381     action = 0xdeadbee;
5382     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5383     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5384     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5385     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5386
5387     state = 0xdeadbee;
5388     action = 0xdeadbee;
5389     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5390     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5391     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5392     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5393
5394     state = 0xdeadbee;
5395     action = 0xdeadbee;
5396     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5397     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5398     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5399     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5400
5401     state = 0xdeadbee;
5402     action = 0xdeadbee;
5403     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5406     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5407
5408     state = 0xdeadbee;
5409     action = 0xdeadbee;
5410     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5411     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5412     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5413     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5414
5415     state = 0xdeadbee;
5416     action = 0xdeadbee;
5417     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5418     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5419     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5420     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5421
5422     state = 0xdeadbee;
5423     action = 0xdeadbee;
5424     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5425     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5426     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5427     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5428
5429     state = 0xdeadbee;
5430     action = 0xdeadbee;
5431     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5432     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5433     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5434     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5435
5436     state = 0xdeadbee;
5437     action = 0xdeadbee;
5438     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5439     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5440     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5441     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5442
5443     state = 0xdeadbee;
5444     action = 0xdeadbee;
5445     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5446     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5447     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5448     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5449
5450     state = 0xdeadbee;
5451     action = 0xdeadbee;
5452     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5453     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5454     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5455     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5456
5457     state = 0xdeadbee;
5458     action = 0xdeadbee;
5459     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5460     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5461     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5462     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5463
5464     state = 0xdeadbee;
5465     action = 0xdeadbee;
5466     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5468     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5469     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5470
5471     state = 0xdeadbee;
5472     action = 0xdeadbee;
5473     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5475     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5476     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5477
5478     state = 0xdeadbee;
5479     action = 0xdeadbee;
5480     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5482     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5483     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5484
5485     state = 0xdeadbee;
5486     action = 0xdeadbee;
5487     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5489     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5490     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5491
5492     state = 0xdeadbee;
5493     action = 0xdeadbee;
5494     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5495     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5496     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5497     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5498
5499     state = 0xdeadbee;
5500     action = 0xdeadbee;
5501     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5502     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5503     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5504     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5505
5506     r = MsiDoAction( hpkg, "CostFinalize");
5507     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5508
5509     state = 0xdeadbee;
5510     action = 0xdeadbee;
5511     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5513     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5514     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5515
5516     state = 0xdeadbee;
5517     action = 0xdeadbee;
5518     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5520     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5521     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5522
5523     state = 0xdeadbee;
5524     action = 0xdeadbee;
5525     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5527     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5528     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5529
5530     state = 0xdeadbee;
5531     action = 0xdeadbee;
5532     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5534     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5535     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5536
5537     state = 0xdeadbee;
5538     action = 0xdeadbee;
5539     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5541     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5542     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5543
5544     state = 0xdeadbee;
5545     action = 0xdeadbee;
5546     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5548     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5549     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5550
5551     state = 0xdeadbee;
5552     action = 0xdeadbee;
5553     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5555     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5556     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5557
5558     state = 0xdeadbee;
5559     action = 0xdeadbee;
5560     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5562     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5563     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5564
5565     state = 0xdeadbee;
5566     action = 0xdeadbee;
5567     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5569     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5570     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5571
5572     state = 0xdeadbee;
5573     action = 0xdeadbee;
5574     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5576     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5577     todo_wine ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5578
5579     state = 0xdeadbee;
5580     action = 0xdeadbee;
5581     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5583     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5584     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5585
5586     state = 0xdeadbee;
5587     action = 0xdeadbee;
5588     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5590     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5591     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5592
5593     state = 0xdeadbee;
5594     action = 0xdeadbee;
5595     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5597     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5598     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5599
5600     state = 0xdeadbee;
5601     action = 0xdeadbee;
5602     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5604     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5605     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5606
5607     state = 0xdeadbee;
5608     action = 0xdeadbee;
5609     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5611     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5612     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5613
5614     state = 0xdeadbee;
5615     action = 0xdeadbee;
5616     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5618     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5619     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5620
5621     state = 0xdeadbee;
5622     action = 0xdeadbee;
5623     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5625     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5626     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5627
5628     state = 0xdeadbee;
5629     action = 0xdeadbee;
5630     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5632     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5633     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5634
5635     state = 0xdeadbee;
5636     action = 0xdeadbee;
5637     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5639     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5640     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5641
5642     state = 0xdeadbee;
5643     action = 0xdeadbee;
5644     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5645     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5646     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5647     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5648
5649     state = 0xdeadbee;
5650     action = 0xdeadbee;
5651     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5653     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5654     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5655
5656     state = 0xdeadbee;
5657     action = 0xdeadbee;
5658     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5660     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5661     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5662
5663     state = 0xdeadbee;
5664     action = 0xdeadbee;
5665     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5667     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5668     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5669
5670     state = 0xdeadbee;
5671     action = 0xdeadbee;
5672     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5674     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5675     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5676
5677     state = 0xdeadbee;
5678     action = 0xdeadbee;
5679     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5681     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5682     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5683
5684     state = 0xdeadbee;
5685     action = 0xdeadbee;
5686     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5688     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5689     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5690
5691     state = 0xdeadbee;
5692     action = 0xdeadbee;
5693     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5695     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5696     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
5697
5698     state = 0xdeadbee;
5699     action = 0xdeadbee;
5700     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5701     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5702     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5703     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5704
5705     state = 0xdeadbee;
5706     action = 0xdeadbee;
5707     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5708     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5709     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5710     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5711
5712     state = 0xdeadbee;
5713     action = 0xdeadbee;
5714     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5715     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5716     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5717     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5718
5719     state = 0xdeadbee;
5720     action = 0xdeadbee;
5721     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5722     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5723     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5724     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5725
5726     state = 0xdeadbee;
5727     action = 0xdeadbee;
5728     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5729     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5730     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5731     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5732
5733     state = 0xdeadbee;
5734     action = 0xdeadbee;
5735     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5736     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5737     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5738     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5739
5740     MsiCloseHandle(hpkg);
5741
5742     /* uninstall the product */
5743     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
5744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5745
5746     /* all features installed from source */
5747     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
5748     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5749
5750     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
5751     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
5752
5753     /* this property must not be in the saved msi file */
5754     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
5755     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
5756
5757     r = package_from_db( hdb, &hpkg );
5758     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5759
5760     state = 0xdeadbee;
5761     action = 0xdeadbee;
5762     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5763     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5764     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5765     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5766
5767     state = 0xdeadbee;
5768     action = 0xdeadbee;
5769     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5770     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5771     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5772     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5773
5774     state = 0xdeadbee;
5775     action = 0xdeadbee;
5776     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5777     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5778     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5779     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5780
5781     state = 0xdeadbee;
5782     action = 0xdeadbee;
5783     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5784     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5785     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5786     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5787
5788     state = 0xdeadbee;
5789     action = 0xdeadbee;
5790     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5791     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5792     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5793     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5794
5795     state = 0xdeadbee;
5796     action = 0xdeadbee;
5797     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5798     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5799     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5800     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5801
5802     state = 0xdeadbee;
5803     action = 0xdeadbee;
5804     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5805     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5806     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5807     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5808
5809     state = 0xdeadbee;
5810     action = 0xdeadbee;
5811     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
5812     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5813     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5814     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5815
5816     state = 0xdeadbee;
5817     action = 0xdeadbee;
5818     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
5819     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5820     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5821     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5822
5823     state = 0xdeadbee;
5824     action = 0xdeadbee;
5825     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
5826     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5827     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5828     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5829
5830     state = 0xdeadbee;
5831     action = 0xdeadbee;
5832     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
5833     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
5834     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5835     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5836
5837     state = 0xdeadbee;
5838     action = 0xdeadbee;
5839     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5840     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5841     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5842     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5843
5844     state = 0xdeadbee;
5845     action = 0xdeadbee;
5846     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5847     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5848     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5849     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5850
5851     state = 0xdeadbee;
5852     action = 0xdeadbee;
5853     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5854     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5855     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5856     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5857
5858     state = 0xdeadbee;
5859     action = 0xdeadbee;
5860     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5861     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5862     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5863     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5864
5865     state = 0xdeadbee;
5866     action = 0xdeadbee;
5867     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5868     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5869     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5870     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5871
5872     state = 0xdeadbee;
5873     action = 0xdeadbee;
5874     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5875     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5876     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5877     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5878
5879     state = 0xdeadbee;
5880     action = 0xdeadbee;
5881     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5882     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5883     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5884     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5885
5886     state = 0xdeadbee;
5887     action = 0xdeadbee;
5888     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5889     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5890     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5891     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5892
5893     state = 0xdeadbee;
5894     action = 0xdeadbee;
5895     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5896     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5897     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5898     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5899
5900     state = 0xdeadbee;
5901     action = 0xdeadbee;
5902     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5903     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5904     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5905     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5906
5907     state = 0xdeadbee;
5908     action = 0xdeadbee;
5909     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5910     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5911     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5912     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5913
5914     state = 0xdeadbee;
5915     action = 0xdeadbee;
5916     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5917     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5918     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5919     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5920
5921     state = 0xdeadbee;
5922     action = 0xdeadbee;
5923     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5924     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5925     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5926     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5927
5928     state = 0xdeadbee;
5929     action = 0xdeadbee;
5930     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5931     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5932     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5933     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5934
5935     state = 0xdeadbee;
5936     action = 0xdeadbee;
5937     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5938     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5939     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5940     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5941
5942     state = 0xdeadbee;
5943     action = 0xdeadbee;
5944     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5945     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5946     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5947     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5948
5949     state = 0xdeadbee;
5950     action = 0xdeadbee;
5951     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5952     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5953     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5954     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5955
5956     state = 0xdeadbee;
5957     action = 0xdeadbee;
5958     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5959     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5960     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5961     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5962
5963     state = 0xdeadbee;
5964     action = 0xdeadbee;
5965     r = MsiGetComponentState(hpkg, "tau", &state, &action);
5966     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5967     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5968     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5969
5970     state = 0xdeadbee;
5971     action = 0xdeadbee;
5972     r = MsiGetComponentState(hpkg, "phi", &state, &action);
5973     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5974     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5975     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5976
5977     state = 0xdeadbee;
5978     action = 0xdeadbee;
5979     r = MsiGetComponentState(hpkg, "chi", &state, &action);
5980     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5981     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5982     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5983
5984     state = 0xdeadbee;
5985     action = 0xdeadbee;
5986     r = MsiGetComponentState(hpkg, "psi", &state, &action);
5987     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5988     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5989     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5990
5991     r = MsiDoAction( hpkg, "CostInitialize");
5992     ok( r == ERROR_SUCCESS, "cost init failed\n");
5993
5994     state = 0xdeadbee;
5995     action = 0xdeadbee;
5996     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5997     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5998     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5999     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6000
6001     state = 0xdeadbee;
6002     action = 0xdeadbee;
6003     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6004     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6005     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6006     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6007
6008     state = 0xdeadbee;
6009     action = 0xdeadbee;
6010     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6011     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6012     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6013     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6014
6015     state = 0xdeadbee;
6016     action = 0xdeadbee;
6017     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6018     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6019     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6020     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6021
6022     state = 0xdeadbee;
6023     action = 0xdeadbee;
6024     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6025     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6026     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6027     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6028
6029     state = 0xdeadbee;
6030     action = 0xdeadbee;
6031     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6032     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6033     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6034     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6035
6036     state = 0xdeadbee;
6037     action = 0xdeadbee;
6038     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6039     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6040     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6041     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6042
6043     state = 0xdeadbee;
6044     action = 0xdeadbee;
6045     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6046     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6047     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6048     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6049
6050     state = 0xdeadbee;
6051     action = 0xdeadbee;
6052     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6053     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6054     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6055     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6056
6057     state = 0xdeadbee;
6058     action = 0xdeadbee;
6059     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6060     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6061     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6062     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6063
6064     state = 0xdeadbee;
6065     action = 0xdeadbee;
6066     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6067     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6068     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6069     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6070
6071     state = 0xdeadbee;
6072     action = 0xdeadbee;
6073     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6074     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6075     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6076     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6077
6078     state = 0xdeadbee;
6079     action = 0xdeadbee;
6080     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6081     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6082     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6083     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6084
6085     state = 0xdeadbee;
6086     action = 0xdeadbee;
6087     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6088     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6089     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6090     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6091
6092     state = 0xdeadbee;
6093     action = 0xdeadbee;
6094     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6095     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6096     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6097     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6098
6099     state = 0xdeadbee;
6100     action = 0xdeadbee;
6101     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6102     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6103     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6104     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6105
6106     state = 0xdeadbee;
6107     action = 0xdeadbee;
6108     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6109     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6110     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6111     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6112
6113     state = 0xdeadbee;
6114     action = 0xdeadbee;
6115     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6116     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6117     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6118     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6119
6120     state = 0xdeadbee;
6121     action = 0xdeadbee;
6122     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6123     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6124     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6125     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6126
6127     state = 0xdeadbee;
6128     action = 0xdeadbee;
6129     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6130     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6131     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6132     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6133
6134     state = 0xdeadbee;
6135     action = 0xdeadbee;
6136     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6137     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6138     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6139     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6140
6141     state = 0xdeadbee;
6142     action = 0xdeadbee;
6143     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6144     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6145     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6146     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6147
6148     state = 0xdeadbee;
6149     action = 0xdeadbee;
6150     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6151     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6152     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6153     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6154
6155     state = 0xdeadbee;
6156     action = 0xdeadbee;
6157     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6158     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6159     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6160     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6161
6162     state = 0xdeadbee;
6163     action = 0xdeadbee;
6164     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6166     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6167     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6168
6169     state = 0xdeadbee;
6170     action = 0xdeadbee;
6171     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6172     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6173     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6174     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6175
6176     state = 0xdeadbee;
6177     action = 0xdeadbee;
6178     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6179     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6180     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6181     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6182
6183     state = 0xdeadbee;
6184     action = 0xdeadbee;
6185     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6186     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6187     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6188     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6189
6190     state = 0xdeadbee;
6191     action = 0xdeadbee;
6192     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6193     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6194     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6195     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6196
6197     state = 0xdeadbee;
6198     action = 0xdeadbee;
6199     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6200     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6201     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6202     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6203
6204     state = 0xdeadbee;
6205     action = 0xdeadbee;
6206     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6207     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6208     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6209     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6210
6211     state = 0xdeadbee;
6212     action = 0xdeadbee;
6213     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6214     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6215     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6216     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6217
6218     state = 0xdeadbee;
6219     action = 0xdeadbee;
6220     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6221     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6222     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6223     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6224
6225     r = MsiDoAction( hpkg, "FileCost");
6226     ok( r == ERROR_SUCCESS, "file cost failed\n");
6227
6228     state = 0xdeadbee;
6229     action = 0xdeadbee;
6230     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6232     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6233     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6234
6235     state = 0xdeadbee;
6236     action = 0xdeadbee;
6237     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6239     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6240     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6241
6242     state = 0xdeadbee;
6243     action = 0xdeadbee;
6244     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6246     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6247     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6248
6249     state = 0xdeadbee;
6250     action = 0xdeadbee;
6251     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6252     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6253     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6254     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6255
6256     state = 0xdeadbee;
6257     action = 0xdeadbee;
6258     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6259     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6260     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6261     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6262
6263     state = 0xdeadbee;
6264     action = 0xdeadbee;
6265     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6266     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6267     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6268     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6269
6270     state = 0xdeadbee;
6271     action = 0xdeadbee;
6272     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6273     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6274     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6275     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6276
6277     state = 0xdeadbee;
6278     action = 0xdeadbee;
6279     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6280     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6281     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6282     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6283
6284     state = 0xdeadbee;
6285     action = 0xdeadbee;
6286     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6287     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6288     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6289     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6290
6291     state = 0xdeadbee;
6292     action = 0xdeadbee;
6293     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6294     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6295     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6296     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6297
6298     state = 0xdeadbee;
6299     action = 0xdeadbee;
6300     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6301     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6302     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6303     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6304
6305     state = 0xdeadbee;
6306     action = 0xdeadbee;
6307     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6308     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6309     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6310     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6311
6312     state = 0xdeadbee;
6313     action = 0xdeadbee;
6314     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6315     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6316     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6317     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6318
6319     state = 0xdeadbee;
6320     action = 0xdeadbee;
6321     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6322     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6323     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6324     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6325
6326     state = 0xdeadbee;
6327     action = 0xdeadbee;
6328     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6329     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6330     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6331     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6332
6333     state = 0xdeadbee;
6334     action = 0xdeadbee;
6335     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6336     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6337     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6338     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6339
6340     state = 0xdeadbee;
6341     action = 0xdeadbee;
6342     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6343     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6344     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6345     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6346
6347     state = 0xdeadbee;
6348     action = 0xdeadbee;
6349     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6350     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6351     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6352     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6353
6354     state = 0xdeadbee;
6355     action = 0xdeadbee;
6356     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6357     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6358     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6359     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6360
6361     state = 0xdeadbee;
6362     action = 0xdeadbee;
6363     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6364     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6365     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6366     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6367
6368     state = 0xdeadbee;
6369     action = 0xdeadbee;
6370     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6371     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6372     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6373     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6374
6375     state = 0xdeadbee;
6376     action = 0xdeadbee;
6377     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6378     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6379     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6380     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6381
6382     state = 0xdeadbee;
6383     action = 0xdeadbee;
6384     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6385     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6386     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6387     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6388
6389     state = 0xdeadbee;
6390     action = 0xdeadbee;
6391     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6392     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6393     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6394     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6395
6396     state = 0xdeadbee;
6397     action = 0xdeadbee;
6398     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6399     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6400     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6401     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6402
6403     state = 0xdeadbee;
6404     action = 0xdeadbee;
6405     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6406     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6407     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6408     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6409
6410     state = 0xdeadbee;
6411     action = 0xdeadbee;
6412     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6413     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6414     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6415     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6416
6417     state = 0xdeadbee;
6418     action = 0xdeadbee;
6419     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6420     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6421     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6422     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6423
6424     state = 0xdeadbee;
6425     action = 0xdeadbee;
6426     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6427     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6428     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6429     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6430
6431     state = 0xdeadbee;
6432     action = 0xdeadbee;
6433     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6434     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6435     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6436     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6437
6438     state = 0xdeadbee;
6439     action = 0xdeadbee;
6440     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6441     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6442     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6443     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6444
6445     state = 0xdeadbee;
6446     action = 0xdeadbee;
6447     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6448     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6449     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6450     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6451
6452     state = 0xdeadbee;
6453     action = 0xdeadbee;
6454     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6455     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6456     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6457     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6458
6459     r = MsiDoAction( hpkg, "CostFinalize");
6460     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
6461
6462     state = 0xdeadbee;
6463     action = 0xdeadbee;
6464     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6465     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6466     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6467     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6468
6469     state = 0xdeadbee;
6470     action = 0xdeadbee;
6471     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6472     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6473     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6474     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6475
6476     state = 0xdeadbee;
6477     action = 0xdeadbee;
6478     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6479     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6480     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6481     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6482
6483     state = 0xdeadbee;
6484     action = 0xdeadbee;
6485     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6486     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6487     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6488     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6489
6490     state = 0xdeadbee;
6491     action = 0xdeadbee;
6492     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6493     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6494     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6495     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6496
6497     state = 0xdeadbee;
6498     action = 0xdeadbee;
6499     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6500     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6501     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6502     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6503
6504     state = 0xdeadbee;
6505     action = 0xdeadbee;
6506     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6507     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6508     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6509     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6510
6511     state = 0xdeadbee;
6512     action = 0xdeadbee;
6513     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6514     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6515     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6516     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6517
6518     state = 0xdeadbee;
6519     action = 0xdeadbee;
6520     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6521     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6522     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6523     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6524
6525     state = 0xdeadbee;
6526     action = 0xdeadbee;
6527     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6528     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6529     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6530     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
6531
6532     state = 0xdeadbee;
6533     action = 0xdeadbee;
6534     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6535     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6536     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6537     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6538
6539     state = 0xdeadbee;
6540     action = 0xdeadbee;
6541     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6542     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6543     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6544     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6545
6546     state = 0xdeadbee;
6547     action = 0xdeadbee;
6548     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6549     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6550     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6551     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6552
6553     state = 0xdeadbee;
6554     action = 0xdeadbee;
6555     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6556     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6557     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6558     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6559
6560     state = 0xdeadbee;
6561     action = 0xdeadbee;
6562     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6563     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6564     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6565     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6566
6567     state = 0xdeadbee;
6568     action = 0xdeadbee;
6569     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6570     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6571     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6572     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6573
6574     state = 0xdeadbee;
6575     action = 0xdeadbee;
6576     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6577     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6578     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6579     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6580
6581     state = 0xdeadbee;
6582     action = 0xdeadbee;
6583     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6584     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6585     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6586     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6587
6588     state = 0xdeadbee;
6589     action = 0xdeadbee;
6590     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6591     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6592     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6593     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6594
6595     state = 0xdeadbee;
6596     action = 0xdeadbee;
6597     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6598     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6599     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6600     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6601
6602     state = 0xdeadbee;
6603     action = 0xdeadbee;
6604     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6605     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6606     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
6607     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6608
6609     state = 0xdeadbee;
6610     action = 0xdeadbee;
6611     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6612     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6613     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6614     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6615
6616     state = 0xdeadbee;
6617     action = 0xdeadbee;
6618     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6619     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6620     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6621     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6622
6623     state = 0xdeadbee;
6624     action = 0xdeadbee;
6625     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6626     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6627     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6628     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6629
6630     state = 0xdeadbee;
6631     action = 0xdeadbee;
6632     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6633     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6634     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6635     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6636
6637     state = 0xdeadbee;
6638     action = 0xdeadbee;
6639     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6640     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6641     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6642     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6643
6644     state = 0xdeadbee;
6645     action = 0xdeadbee;
6646     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6647     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6648     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6649     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6650
6651     state = 0xdeadbee;
6652     action = 0xdeadbee;
6653     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6654     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6655     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6656     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6657
6658     state = 0xdeadbee;
6659     action = 0xdeadbee;
6660     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6661     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6662     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
6663     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
6664
6665     state = 0xdeadbee;
6666     action = 0xdeadbee;
6667     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6668     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6669     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6670     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6671
6672     state = 0xdeadbee;
6673     action = 0xdeadbee;
6674     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6675     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6676     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6677     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6678
6679     state = 0xdeadbee;
6680     action = 0xdeadbee;
6681     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6682     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6683     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6684     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6685
6686     state = 0xdeadbee;
6687     action = 0xdeadbee;
6688     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6689     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6690     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
6691     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6692
6693     MsiCloseHandle(hpkg);
6694
6695     /* reinstall the product */
6696     r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
6697     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6698
6699     r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
6700     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
6701
6702     /* this property must not be in the saved msi file */
6703     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
6704     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
6705
6706     r = package_from_db( hdb, &hpkg );
6707     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6708
6709     state = 0xdeadbee;
6710     action = 0xdeadbee;
6711     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6712     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6713     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6714     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6715
6716     state = 0xdeadbee;
6717     action = 0xdeadbee;
6718     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6719     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6720     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6721     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6722
6723     state = 0xdeadbee;
6724     action = 0xdeadbee;
6725     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6726     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6727     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6728     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6729
6730     state = 0xdeadbee;
6731     action = 0xdeadbee;
6732     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6733     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6734     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6735     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6736
6737     state = 0xdeadbee;
6738     action = 0xdeadbee;
6739     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6740     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6741     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6742     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6743
6744     state = 0xdeadbee;
6745     action = 0xdeadbee;
6746     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6747     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6748     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6749     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6750
6751     state = 0xdeadbee;
6752     action = 0xdeadbee;
6753     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6754     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6755     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6756     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6757
6758     state = 0xdeadbee;
6759     action = 0xdeadbee;
6760     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6761     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6762     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6763     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6764
6765     state = 0xdeadbee;
6766     action = 0xdeadbee;
6767     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
6768     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6769     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6770     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6771
6772     state = 0xdeadbee;
6773     action = 0xdeadbee;
6774     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
6775     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6776     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6777     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6778
6779     state = 0xdeadbee;
6780     action = 0xdeadbee;
6781     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
6782     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
6783     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6784     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6785
6786     state = 0xdeadbee;
6787     action = 0xdeadbee;
6788     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
6789     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6790     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6791     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6792
6793     state = 0xdeadbee;
6794     action = 0xdeadbee;
6795     r = MsiGetComponentState(hpkg, "beta", &state, &action);
6796     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6797     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6798     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6799
6800     state = 0xdeadbee;
6801     action = 0xdeadbee;
6802     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
6803     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6804     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6805     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6806
6807     state = 0xdeadbee;
6808     action = 0xdeadbee;
6809     r = MsiGetComponentState(hpkg, "theta", &state, &action);
6810     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6811     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6812     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6813
6814     state = 0xdeadbee;
6815     action = 0xdeadbee;
6816     r = MsiGetComponentState(hpkg, "delta", &state, &action);
6817     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6818     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6819     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6820
6821     state = 0xdeadbee;
6822     action = 0xdeadbee;
6823     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
6824     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6825     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6826     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6827
6828     state = 0xdeadbee;
6829     action = 0xdeadbee;
6830     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
6831     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6832     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6833     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6834
6835     state = 0xdeadbee;
6836     action = 0xdeadbee;
6837     r = MsiGetComponentState(hpkg, "iota", &state, &action);
6838     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6839     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6840     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6841
6842     state = 0xdeadbee;
6843     action = 0xdeadbee;
6844     r = MsiGetComponentState(hpkg, "eta", &state, &action);
6845     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6846     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6847     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6848
6849     state = 0xdeadbee;
6850     action = 0xdeadbee;
6851     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
6852     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6853     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6854     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6855
6856     state = 0xdeadbee;
6857     action = 0xdeadbee;
6858     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
6859     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6860     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6861     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6862
6863     state = 0xdeadbee;
6864     action = 0xdeadbee;
6865     r = MsiGetComponentState(hpkg, "mu", &state, &action);
6866     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6867     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6868     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6869
6870     state = 0xdeadbee;
6871     action = 0xdeadbee;
6872     r = MsiGetComponentState(hpkg, "nu", &state, &action);
6873     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6874     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6875     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6876
6877     state = 0xdeadbee;
6878     action = 0xdeadbee;
6879     r = MsiGetComponentState(hpkg, "xi", &state, &action);
6880     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6881     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6882     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6883
6884     state = 0xdeadbee;
6885     action = 0xdeadbee;
6886     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
6887     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6888     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6889     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6890
6891     state = 0xdeadbee;
6892     action = 0xdeadbee;
6893     r = MsiGetComponentState(hpkg, "pi", &state, &action);
6894     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6895     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6896     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6897
6898     state = 0xdeadbee;
6899     action = 0xdeadbee;
6900     r = MsiGetComponentState(hpkg, "rho", &state, &action);
6901     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6902     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6903     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6904
6905     state = 0xdeadbee;
6906     action = 0xdeadbee;
6907     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
6908     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6909     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6910     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6911
6912     state = 0xdeadbee;
6913     action = 0xdeadbee;
6914     r = MsiGetComponentState(hpkg, "tau", &state, &action);
6915     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6916     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6917     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6918
6919     state = 0xdeadbee;
6920     action = 0xdeadbee;
6921     r = MsiGetComponentState(hpkg, "phi", &state, &action);
6922     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6923     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6924     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6925
6926     state = 0xdeadbee;
6927     action = 0xdeadbee;
6928     r = MsiGetComponentState(hpkg, "chi", &state, &action);
6929     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6930     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6931     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6932
6933     state = 0xdeadbee;
6934     action = 0xdeadbee;
6935     r = MsiGetComponentState(hpkg, "psi", &state, &action);
6936     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
6937     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
6938     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
6939
6940     r = MsiDoAction( hpkg, "CostInitialize");
6941     ok( r == ERROR_SUCCESS, "cost init failed\n");
6942
6943     state = 0xdeadbee;
6944     action = 0xdeadbee;
6945     r = MsiGetFeatureState(hpkg, "one", &state, &action);
6946     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6947     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6948     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6949
6950     state = 0xdeadbee;
6951     action = 0xdeadbee;
6952     r = MsiGetFeatureState(hpkg, "two", &state, &action);
6953     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6954     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6955     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6956
6957     state = 0xdeadbee;
6958     action = 0xdeadbee;
6959     r = MsiGetFeatureState(hpkg, "three", &state, &action);
6960     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6961     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6962     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6963
6964     state = 0xdeadbee;
6965     action = 0xdeadbee;
6966     r = MsiGetFeatureState(hpkg, "four", &state, &action);
6967     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6968     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6969     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6970
6971     state = 0xdeadbee;
6972     action = 0xdeadbee;
6973     r = MsiGetFeatureState(hpkg, "five", &state, &action);
6974     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6975     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6976     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6977
6978     state = 0xdeadbee;
6979     action = 0xdeadbee;
6980     r = MsiGetFeatureState(hpkg, "six", &state, &action);
6981     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6982     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6983     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6984
6985     state = 0xdeadbee;
6986     action = 0xdeadbee;
6987     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
6988     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6989     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6990     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6991
6992     state = 0xdeadbee;
6993     action = 0xdeadbee;
6994     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
6995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
6996     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
6997     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
6998
6999     state = 0xdeadbee;
7000     action = 0xdeadbee;
7001     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7002     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7003     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7004     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7005
7006     state = 0xdeadbee;
7007     action = 0xdeadbee;
7008     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7009     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7010     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7011     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7012
7013     state = 0xdeadbee;
7014     action = 0xdeadbee;
7015     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7017     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7018     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7019
7020     state = 0xdeadbee;
7021     action = 0xdeadbee;
7022     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7023     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7024     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7025     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7026
7027     state = 0xdeadbee;
7028     action = 0xdeadbee;
7029     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7030     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7031     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7032     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7033
7034     state = 0xdeadbee;
7035     action = 0xdeadbee;
7036     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7037     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7038     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7039     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7040
7041     state = 0xdeadbee;
7042     action = 0xdeadbee;
7043     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7045     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7046     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7047
7048     state = 0xdeadbee;
7049     action = 0xdeadbee;
7050     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7052     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7053     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7054
7055     state = 0xdeadbee;
7056     action = 0xdeadbee;
7057     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7059     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7060     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7061
7062     state = 0xdeadbee;
7063     action = 0xdeadbee;
7064     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7066     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7067     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7068
7069     state = 0xdeadbee;
7070     action = 0xdeadbee;
7071     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7072     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7073     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7074     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7075
7076     state = 0xdeadbee;
7077     action = 0xdeadbee;
7078     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7079     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7080     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7081     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7082
7083     state = 0xdeadbee;
7084     action = 0xdeadbee;
7085     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7086     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7087     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7088     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7089
7090     state = 0xdeadbee;
7091     action = 0xdeadbee;
7092     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7093     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7094     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7095     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7096
7097     state = 0xdeadbee;
7098     action = 0xdeadbee;
7099     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7100     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7101     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7102     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7103
7104     state = 0xdeadbee;
7105     action = 0xdeadbee;
7106     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7107     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7108     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7109     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7110
7111     state = 0xdeadbee;
7112     action = 0xdeadbee;
7113     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7114     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7115     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7116     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7117
7118     state = 0xdeadbee;
7119     action = 0xdeadbee;
7120     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7121     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7122     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7123     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7124
7125     state = 0xdeadbee;
7126     action = 0xdeadbee;
7127     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7128     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7129     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7130     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7131
7132     state = 0xdeadbee;
7133     action = 0xdeadbee;
7134     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7136     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7137     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7138
7139     state = 0xdeadbee;
7140     action = 0xdeadbee;
7141     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7142     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7143     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7144     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7145
7146     state = 0xdeadbee;
7147     action = 0xdeadbee;
7148     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7149     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7150     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7151     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7152
7153     state = 0xdeadbee;
7154     action = 0xdeadbee;
7155     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7156     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7157     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7158     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7159
7160     state = 0xdeadbee;
7161     action = 0xdeadbee;
7162     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7163     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7164     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7165     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7166
7167     state = 0xdeadbee;
7168     action = 0xdeadbee;
7169     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7170     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7171     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7172     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7173
7174     r = MsiDoAction( hpkg, "FileCost");
7175     ok( r == ERROR_SUCCESS, "file cost failed\n");
7176
7177     state = 0xdeadbee;
7178     action = 0xdeadbee;
7179     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7180     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7181     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7182     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7183
7184     state = 0xdeadbee;
7185     action = 0xdeadbee;
7186     r = MsiGetFeatureState(hpkg, "two", &state, &action);
7187     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7188     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7189     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7190
7191     state = 0xdeadbee;
7192     action = 0xdeadbee;
7193     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7194     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7195     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7196     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7197
7198     state = 0xdeadbee;
7199     action = 0xdeadbee;
7200     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7201     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7202     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7203     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7204
7205     state = 0xdeadbee;
7206     action = 0xdeadbee;
7207     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7208     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7209     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7210     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7211
7212     state = 0xdeadbee;
7213     action = 0xdeadbee;
7214     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7215     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7216     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7217     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7218
7219     state = 0xdeadbee;
7220     action = 0xdeadbee;
7221     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7222     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7223     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7224     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7225
7226     state = 0xdeadbee;
7227     action = 0xdeadbee;
7228     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7229     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7230     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7231     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7232
7233     state = 0xdeadbee;
7234     action = 0xdeadbee;
7235     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7236     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7237     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7238     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7239
7240     state = 0xdeadbee;
7241     action = 0xdeadbee;
7242     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7243     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7244     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7245     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7246
7247     state = 0xdeadbee;
7248     action = 0xdeadbee;
7249     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7250     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7251     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7252     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7253
7254     state = 0xdeadbee;
7255     action = 0xdeadbee;
7256     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7257     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7258     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7259     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7260
7261     state = 0xdeadbee;
7262     action = 0xdeadbee;
7263     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7264     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7265     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7266     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7267
7268     state = 0xdeadbee;
7269     action = 0xdeadbee;
7270     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7271     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7272     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7273     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7274
7275     state = 0xdeadbee;
7276     action = 0xdeadbee;
7277     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7278     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7279     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7280     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7281
7282     state = 0xdeadbee;
7283     action = 0xdeadbee;
7284     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7285     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7286     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7287     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7288
7289     state = 0xdeadbee;
7290     action = 0xdeadbee;
7291     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7292     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7293     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7294     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7295
7296     state = 0xdeadbee;
7297     action = 0xdeadbee;
7298     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7299     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7300     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7301     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7302
7303     state = 0xdeadbee;
7304     action = 0xdeadbee;
7305     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7306     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7307     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7308     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7309
7310     state = 0xdeadbee;
7311     action = 0xdeadbee;
7312     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7313     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7314     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7315     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7316
7317     state = 0xdeadbee;
7318     action = 0xdeadbee;
7319     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7320     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7321     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7322     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7323
7324     state = 0xdeadbee;
7325     action = 0xdeadbee;
7326     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7327     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7328     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7329     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7330
7331     state = 0xdeadbee;
7332     action = 0xdeadbee;
7333     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7334     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7335     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7336     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7337
7338     state = 0xdeadbee;
7339     action = 0xdeadbee;
7340     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7341     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7342     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7343     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7344
7345     state = 0xdeadbee;
7346     action = 0xdeadbee;
7347     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7348     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7349     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7350     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7351
7352     state = 0xdeadbee;
7353     action = 0xdeadbee;
7354     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7355     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7356     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7357     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7358
7359     state = 0xdeadbee;
7360     action = 0xdeadbee;
7361     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7362     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7363     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7364     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7365
7366     state = 0xdeadbee;
7367     action = 0xdeadbee;
7368     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7369     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7370     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7371     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7372
7373     state = 0xdeadbee;
7374     action = 0xdeadbee;
7375     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7376     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7377     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7378     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7379
7380     state = 0xdeadbee;
7381     action = 0xdeadbee;
7382     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7383     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7384     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7385     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7386
7387     state = 0xdeadbee;
7388     action = 0xdeadbee;
7389     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7390     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7391     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7392     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7393
7394     state = 0xdeadbee;
7395     action = 0xdeadbee;
7396     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7397     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7398     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7399     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7400
7401     state = 0xdeadbee;
7402     action = 0xdeadbee;
7403     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7406     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7407
7408     r = MsiDoAction( hpkg, "CostFinalize");
7409     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
7410
7411     state = 0xdeadbee;
7412     action = 0xdeadbee;
7413     r = MsiGetFeatureState(hpkg, "one", &state, &action);
7414     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7415     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7416     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7417
7418     state = 0xdeadbee;
7419     action = 0xdeadbee;
7420     r = MsiGetFeatureState(hpkg, "two", &state, &action);
7421     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7422     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7423     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7424
7425     state = 0xdeadbee;
7426     action = 0xdeadbee;
7427     r = MsiGetFeatureState(hpkg, "three", &state, &action);
7428     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7429     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7430     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7431
7432     state = 0xdeadbee;
7433     action = 0xdeadbee;
7434     r = MsiGetFeatureState(hpkg, "four", &state, &action);
7435     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7436     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7437     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7438
7439     state = 0xdeadbee;
7440     action = 0xdeadbee;
7441     r = MsiGetFeatureState(hpkg, "five", &state, &action);
7442     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7443     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7444     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7445
7446     state = 0xdeadbee;
7447     action = 0xdeadbee;
7448     r = MsiGetFeatureState(hpkg, "six", &state, &action);
7449     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7450     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7451     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7452
7453     state = 0xdeadbee;
7454     action = 0xdeadbee;
7455     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
7456     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7457     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7458     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7459
7460     state = 0xdeadbee;
7461     action = 0xdeadbee;
7462     r = MsiGetFeatureState(hpkg, "eight", &state, &action);
7463     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7464     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7465     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7466
7467     state = 0xdeadbee;
7468     action = 0xdeadbee;
7469     r = MsiGetFeatureState(hpkg, "nine", &state, &action);
7470     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7471     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7472     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7473
7474     state = 0xdeadbee;
7475     action = 0xdeadbee;
7476     r = MsiGetFeatureState(hpkg, "ten", &state, &action);
7477     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7478     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7479     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7480
7481     state = 0xdeadbee;
7482     action = 0xdeadbee;
7483     r = MsiGetFeatureState(hpkg, "eleven", &state, &action);
7484     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7485     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7486     todo_wine ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7487
7488     state = 0xdeadbee;
7489     action = 0xdeadbee;
7490     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
7491     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7492     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7493     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7494
7495     state = 0xdeadbee;
7496     action = 0xdeadbee;
7497     r = MsiGetComponentState(hpkg, "beta", &state, &action);
7498     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7499     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7500     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7501
7502     state = 0xdeadbee;
7503     action = 0xdeadbee;
7504     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
7505     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7506     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7507     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7508
7509     state = 0xdeadbee;
7510     action = 0xdeadbee;
7511     r = MsiGetComponentState(hpkg, "theta", &state, &action);
7512     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7513     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7514     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7515
7516     state = 0xdeadbee;
7517     action = 0xdeadbee;
7518     r = MsiGetComponentState(hpkg, "delta", &state, &action);
7519     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7520     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7521     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7522
7523     state = 0xdeadbee;
7524     action = 0xdeadbee;
7525     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
7526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7527     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7528     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7529
7530     state = 0xdeadbee;
7531     action = 0xdeadbee;
7532     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
7533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7534     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7535     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7536
7537     state = 0xdeadbee;
7538     action = 0xdeadbee;
7539     r = MsiGetComponentState(hpkg, "iota", &state, &action);
7540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7541     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7542     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7543
7544     state = 0xdeadbee;
7545     action = 0xdeadbee;
7546     r = MsiGetComponentState(hpkg, "eta", &state, &action);
7547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7548     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7549     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7550
7551     state = 0xdeadbee;
7552     action = 0xdeadbee;
7553     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
7554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7555     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7556     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7557
7558     state = 0xdeadbee;
7559     action = 0xdeadbee;
7560     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
7561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7562     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7563     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7564
7565     state = 0xdeadbee;
7566     action = 0xdeadbee;
7567     r = MsiGetComponentState(hpkg, "mu", &state, &action);
7568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7569     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7570     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7571
7572     state = 0xdeadbee;
7573     action = 0xdeadbee;
7574     r = MsiGetComponentState(hpkg, "nu", &state, &action);
7575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7576     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7577     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7578
7579     state = 0xdeadbee;
7580     action = 0xdeadbee;
7581     r = MsiGetComponentState(hpkg, "xi", &state, &action);
7582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7583     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7584     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7585
7586     state = 0xdeadbee;
7587     action = 0xdeadbee;
7588     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
7589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7590     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7591     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7592
7593     state = 0xdeadbee;
7594     action = 0xdeadbee;
7595     r = MsiGetComponentState(hpkg, "pi", &state, &action);
7596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7597     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7598     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7599
7600     state = 0xdeadbee;
7601     action = 0xdeadbee;
7602     r = MsiGetComponentState(hpkg, "rho", &state, &action);
7603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7604     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7605     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7606
7607     state = 0xdeadbee;
7608     action = 0xdeadbee;
7609     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
7610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7611     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
7612     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7613
7614     state = 0xdeadbee;
7615     action = 0xdeadbee;
7616     r = MsiGetComponentState(hpkg, "tau", &state, &action);
7617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7618     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7619     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7620
7621     state = 0xdeadbee;
7622     action = 0xdeadbee;
7623     r = MsiGetComponentState(hpkg, "phi", &state, &action);
7624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7625     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7626     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7627
7628     state = 0xdeadbee;
7629     action = 0xdeadbee;
7630     r = MsiGetComponentState(hpkg, "chi", &state, &action);
7631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7632     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7633     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7634
7635     state = 0xdeadbee;
7636     action = 0xdeadbee;
7637     r = MsiGetComponentState(hpkg, "psi", &state, &action);
7638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7639     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
7640     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7641
7642     MsiCloseHandle(hpkg);
7643
7644     /* uninstall the product */
7645     r = MsiInstallProduct(msifile4, "REMOVE=ALL");
7646     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7647
7648     DeleteFileA(msifile);
7649     DeleteFileA(msifile2);
7650     DeleteFileA(msifile3);
7651     DeleteFileA(msifile4);
7652 }
7653
7654 static void test_getproperty(void)
7655 {
7656     MSIHANDLE hPackage = 0;
7657     char prop[100];
7658     static CHAR empty[] = "";
7659     DWORD size;
7660     UINT r;
7661
7662     r = package_from_db(create_package_db(), &hPackage);
7663     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7664     {
7665         skip("Not enough rights to perform tests\n");
7666         DeleteFile(msifile);
7667         return;
7668     }
7669     ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
7670
7671     /* set the property */
7672     r = MsiSetProperty(hPackage, "Name", "Value");
7673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7674
7675     /* retrieve the size, NULL pointer */
7676     size = 0;
7677     r = MsiGetProperty(hPackage, "Name", NULL, &size);
7678     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7679     ok( size == 5, "Expected 5, got %d\n", size);
7680
7681     /* retrieve the size, empty string */
7682     size = 0;
7683     r = MsiGetProperty(hPackage, "Name", empty, &size);
7684     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7685     ok( size == 5, "Expected 5, got %d\n", size);
7686
7687     /* don't change size */
7688     r = MsiGetProperty(hPackage, "Name", prop, &size);
7689     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
7690     ok( size == 5, "Expected 5, got %d\n", size);
7691     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
7692
7693     /* increase the size by 1 */
7694     size++;
7695     r = MsiGetProperty(hPackage, "Name", prop, &size);
7696     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7697     ok( size == 5, "Expected 5, got %d\n", size);
7698     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
7699
7700     r = MsiCloseHandle( hPackage);
7701     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
7702     DeleteFile(msifile);
7703 }
7704
7705 static void test_removefiles(void)
7706 {
7707     MSIHANDLE hpkg;
7708     UINT r;
7709     MSIHANDLE hdb;
7710
7711     hdb = create_package_db();
7712     ok ( hdb, "failed to create package database\n" );
7713
7714     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7715     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7716
7717     r = create_feature_table( hdb );
7718     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7719
7720     r = create_component_table( hdb );
7721     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7722
7723     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
7724     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7725
7726     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
7727     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7728
7729     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
7730     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7731
7732     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
7733     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7734
7735     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
7736     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7737
7738     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
7739     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7740
7741     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
7742     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7743
7744     r = create_feature_components_table( hdb );
7745     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7746
7747     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
7748     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7749
7750     r = add_feature_components_entry( hdb, "'one', 'helium'" );
7751     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7752
7753     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
7754     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7755
7756     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
7757     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7758
7759     r = add_feature_components_entry( hdb, "'one', 'boron'" );
7760     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7761
7762     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
7763     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7764
7765     r = create_file_table( hdb );
7766     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7767
7768     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
7769     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7770
7771     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
7772     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7773
7774     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
7775     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7776
7777     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
7778     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7779
7780     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
7781     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7782
7783     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
7784     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7785
7786     r = create_remove_file_table( hdb );
7787     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
7788
7789     r = package_from_db( hdb, &hpkg );
7790     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7791     {
7792         skip("Not enough rights to perform tests\n");
7793         DeleteFile(msifile);
7794         return;
7795     }
7796     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7797
7798     MsiCloseHandle( hdb );
7799
7800     create_test_file( "hydrogen.txt" );
7801     create_test_file( "helium.txt" );
7802     create_test_file( "lithium.txt" );
7803     create_test_file( "beryllium.txt" );
7804     create_test_file( "boron.txt" );
7805     create_test_file( "carbon.txt" );
7806
7807     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
7808     ok( r == ERROR_SUCCESS, "set property failed\n");
7809
7810     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7811
7812     r = MsiDoAction( hpkg, "CostInitialize");
7813     ok( r == ERROR_SUCCESS, "cost init failed\n");
7814
7815     r = MsiDoAction( hpkg, "FileCost");
7816     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7817
7818     r = MsiDoAction( hpkg, "CostFinalize");
7819     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7820
7821     r = MsiDoAction( hpkg, "InstallValidate");
7822     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7823
7824     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
7825     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7826
7827     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
7828     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7829
7830     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
7831     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7832
7833     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
7834     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7835
7836     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
7837     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7838
7839     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
7840     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
7841
7842     r = MsiDoAction( hpkg, "RemoveFiles");
7843     ok( r == ERROR_SUCCESS, "remove files failed\n");
7844
7845     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
7846     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
7847     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
7848     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
7849     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
7850     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
7851
7852     MsiCloseHandle( hpkg );
7853     DeleteFileA(msifile);
7854 }
7855
7856 static void test_appsearch(void)
7857 {
7858     MSIHANDLE hpkg;
7859     UINT r;
7860     MSIHANDLE hdb;
7861     CHAR prop[MAX_PATH];
7862     DWORD size;
7863
7864     hdb = create_package_db();
7865     ok ( hdb, "failed to create package database\n" );
7866
7867     r = create_appsearch_table( hdb );
7868     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
7869
7870     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
7871     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7872
7873     r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
7874     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
7875
7876     r = create_reglocator_table( hdb );
7877     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7878
7879     r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
7880     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7881
7882     r = create_drlocator_table( hdb );
7883     ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
7884
7885     r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
7886     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
7887
7888     r = create_signature_table( hdb );
7889     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
7890
7891     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
7892     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7893
7894     r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
7895     ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
7896
7897     r = package_from_db( hdb, &hpkg );
7898     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7899     {
7900         skip("Not enough rights to perform tests\n");
7901         DeleteFile(msifile);
7902         return;
7903     }
7904     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
7905     MsiCloseHandle( hdb );
7906     if (r != ERROR_SUCCESS)
7907         goto done;
7908
7909     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7910
7911     r = MsiDoAction( hpkg, "AppSearch" );
7912     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
7913
7914     size = sizeof(prop);
7915     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
7916     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7917     todo_wine
7918     {
7919         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
7920     }
7921
7922     size = sizeof(prop);
7923     r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
7924     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
7925
7926 done:
7927     MsiCloseHandle( hpkg );
7928     DeleteFileA(msifile);
7929 }
7930
7931 static void test_appsearch_complocator(void)
7932 {
7933     MSIHANDLE hpkg, hdb;
7934     CHAR path[MAX_PATH];
7935     CHAR prop[MAX_PATH];
7936     LPSTR usersid;
7937     DWORD size;
7938     UINT r;
7939
7940     if (!get_user_sid(&usersid))
7941         return;
7942
7943     if (is_process_limited())
7944     {
7945         skip("process is limited\n");
7946         return;
7947     }
7948
7949     create_test_file("FileName1");
7950     create_test_file("FileName4");
7951     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
7952                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
7953
7954     create_test_file("FileName2");
7955     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
7956                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
7957
7958     create_test_file("FileName3");
7959     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
7960                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
7961
7962     create_test_file("FileName5");
7963     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
7964                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
7965
7966     create_test_file("FileName6");
7967     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
7968                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
7969
7970     create_test_file("FileName7");
7971     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
7972                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
7973
7974     /* dir is FALSE, but we're pretending it's a directory */
7975     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
7976                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
7977
7978     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7979     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
7980                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
7981
7982     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
7983     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
7984                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
7985
7986     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
7987     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
7988                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
7989
7990     hdb = create_package_db();
7991     ok(hdb, "Expected a valid database handle\n");
7992
7993     r = create_appsearch_table(hdb);
7994     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7995
7996     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
7997     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7998
7999     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8001
8002     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8004
8005     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8006     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8007
8008     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8010
8011     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8013
8014     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8015     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8016
8017     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8018     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8019
8020     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8021     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8022
8023     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8025
8026     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8027     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8028
8029     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8030     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8031
8032     r = create_complocator_table(hdb);
8033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8034
8035     /* published component, machine, file, signature, misdbLocatorTypeFile */
8036     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
8037     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8038
8039     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
8040     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
8041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8042
8043     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
8044     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
8045     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8046
8047     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
8048     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
8049     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8050
8051     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
8052     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
8053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8054
8055     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
8056     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
8057     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8058
8059     /* published component, machine, file, no signature, misdbLocatorTypeFile */
8060     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
8061     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8062
8063     /* unpublished component, no signature, misdbLocatorTypeDir */
8064     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
8065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8066
8067     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
8068     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
8069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8070
8071     /* published component, signature w/ ver, misdbLocatorTypeFile */
8072     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
8073     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8074
8075     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
8076     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
8077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8078
8079     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
8080     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
8081     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8082
8083     r = create_signature_table(hdb);
8084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8085
8086     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
8087     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8088
8089     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
8090     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8091
8092     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
8093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8094
8095     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
8096     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8097
8098     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
8099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8100
8101     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8102     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8103
8104     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8105     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8106
8107     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
8108     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8109
8110     r = package_from_db(hdb, &hpkg);
8111     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8112     {
8113         skip("Not enough rights to perform tests\n");
8114         goto error;
8115     }
8116     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8117
8118     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
8119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8120
8121     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8122
8123     r = MsiDoAction(hpkg, "AppSearch");
8124     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8125
8126     size = MAX_PATH;
8127     sprintf(path, "%s\\FileName1", CURR_DIR);
8128     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8130     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8131
8132     size = MAX_PATH;
8133     sprintf(path, "%s\\FileName2", CURR_DIR);
8134     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8135     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8136     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8137
8138     size = MAX_PATH;
8139     sprintf(path, "%s\\FileName3", CURR_DIR);
8140     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8141     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8142     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8143
8144     size = MAX_PATH;
8145     sprintf(path, "%s\\FileName4", CURR_DIR);
8146     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
8147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8148     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8149
8150     size = MAX_PATH;
8151     sprintf(path, "%s\\FileName5", CURR_DIR);
8152     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8153     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8154     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8155
8156     size = MAX_PATH;
8157     sprintf(path, "%s\\", CURR_DIR);
8158     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8159     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8160     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8161
8162     size = MAX_PATH;
8163     sprintf(path, "%s\\", CURR_DIR);
8164     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8165     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8166     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8167
8168     size = MAX_PATH;
8169     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8170     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8171     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
8172
8173     size = MAX_PATH;
8174     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8175     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8176     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8177
8178     size = MAX_PATH;
8179     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
8180     r = MsiGetPropertyA(hpkg, "SIGPROP10", 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     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8186     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8187     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8188
8189     size = MAX_PATH;
8190     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
8191     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8192     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8193     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8194
8195     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
8196                           MSIINSTALLCONTEXT_MACHINE, NULL);
8197     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
8198                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
8199     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
8200                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
8201     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
8202                           MSIINSTALLCONTEXT_MACHINE, NULL);
8203     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
8204                           MSIINSTALLCONTEXT_MACHINE, NULL);
8205     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
8206                           MSIINSTALLCONTEXT_MACHINE, NULL);
8207     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
8208                           MSIINSTALLCONTEXT_MACHINE, NULL);
8209     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
8210                           MSIINSTALLCONTEXT_MACHINE, NULL);
8211     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
8212                           MSIINSTALLCONTEXT_MACHINE, NULL);
8213     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
8214                           MSIINSTALLCONTEXT_MACHINE, NULL);
8215
8216     MsiCloseHandle(hpkg);
8217
8218 error:
8219     DeleteFileA("FileName1");
8220     DeleteFileA("FileName2");
8221     DeleteFileA("FileName3");
8222     DeleteFileA("FileName4");
8223     DeleteFileA("FileName5");
8224     DeleteFileA("FileName6");
8225     DeleteFileA("FileName7");
8226     DeleteFileA("FileName8.dll");
8227     DeleteFileA("FileName9.dll");
8228     DeleteFileA("FileName10.dll");
8229     DeleteFileA(msifile);
8230     LocalFree(usersid);
8231 }
8232
8233 static void test_appsearch_reglocator(void)
8234 {
8235     MSIHANDLE hpkg, hdb;
8236     CHAR path[MAX_PATH], prop[MAX_PATH];
8237     DWORD binary[2], size, val;
8238     BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
8239     HKEY hklm, classes, hkcu, users;
8240     LPSTR pathdata, pathvar, ptr;
8241     LPCSTR str;
8242     LONG res;
8243     UINT r, type = 0;
8244
8245     version = TRUE;
8246     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8247         version = FALSE;
8248
8249     DeleteFileA("test.dll");
8250
8251     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
8252     if (res == ERROR_ACCESS_DENIED)
8253     {
8254         skip("Not enough rights to perform tests\n");
8255         return;
8256     }
8257     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8258
8259     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
8260                          (const BYTE *)"regszdata", 10);
8261     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8262
8263     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
8264     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8265
8266     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
8267                          (const BYTE *)"regszdata", 10);
8268     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8269
8270     users = 0;
8271     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
8272     ok(res == ERROR_SUCCESS ||
8273        broken(res == ERROR_INVALID_PARAMETER),
8274        "Expected ERROR_SUCCESS, got %d\n", res);
8275
8276     if (res == ERROR_SUCCESS)
8277     {
8278         res = RegSetValueExA(users, "Value1", 0, REG_SZ,
8279                              (const BYTE *)"regszdata", 10);
8280         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8281     }
8282
8283     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
8284     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8285
8286     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
8287     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8288
8289     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
8290                          (const BYTE *)"regszdata", 10);
8291     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8292
8293     val = 42;
8294     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
8295                          (const BYTE *)&val, sizeof(DWORD));
8296     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8297
8298     val = -42;
8299     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
8300                          (const BYTE *)&val, sizeof(DWORD));
8301     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8302
8303     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
8304                          (const BYTE *)"%PATH%", 7);
8305     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8306
8307     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
8308                          (const BYTE *)"my%NOVAR%", 10);
8309     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8310
8311     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
8312                          (const BYTE *)"one\0two\0", 9);
8313     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8314
8315     binary[0] = 0x1234abcd;
8316     binary[1] = 0x567890ef;
8317     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
8318                          (const BYTE *)binary, sizeof(binary));
8319     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8320
8321     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
8322                          (const BYTE *)"#regszdata", 11);
8323     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8324
8325     create_test_file("FileName1");
8326     sprintf(path, "%s\\FileName1", CURR_DIR);
8327     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
8328                          (const BYTE *)path, lstrlenA(path) + 1);
8329     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8330
8331     sprintf(path, "%s\\FileName2", CURR_DIR);
8332     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
8333                          (const BYTE *)path, lstrlenA(path) + 1);
8334     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8335
8336     lstrcpyA(path, CURR_DIR);
8337     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
8338                          (const BYTE *)path, lstrlenA(path) + 1);
8339     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8340
8341     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
8342                          (const BYTE *)"", 1);
8343     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8344
8345     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8346     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8347     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
8348                          (const BYTE *)path, lstrlenA(path) + 1);
8349     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8350
8351     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8352     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8353     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
8354                          (const BYTE *)path, lstrlenA(path) + 1);
8355     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8356
8357     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8358     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8359     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
8360                          (const BYTE *)path, lstrlenA(path) + 1);
8361     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8362
8363     sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
8364     res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
8365                          (const BYTE *)path, lstrlenA(path) + 1);
8366
8367     space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
8368     sprintf(path, "%s\\FileName1 -option", CURR_DIR);
8369     res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
8370                          (const BYTE *)path, lstrlenA(path) + 1);
8371
8372     hdb = create_package_db();
8373     ok(hdb, "Expected a valid database handle\n");
8374
8375     r = create_appsearch_table(hdb);
8376     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8377
8378     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8379     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8380
8381     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8383
8384     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8385     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8386
8387     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8388     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8389
8390     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8392
8393     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8394     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8395
8396     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8398
8399     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8400     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8401
8402     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8404
8405     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8406     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8407
8408     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
8409     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8410
8411     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
8412     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8413
8414     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
8415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8416
8417     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
8418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8419
8420     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
8421     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8422
8423     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
8424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8425
8426     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
8427     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8428
8429     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
8430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8431
8432     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
8433     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8434
8435     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
8436     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8437
8438     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
8439     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8440
8441     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
8442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8443
8444     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
8445     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8446
8447     r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
8448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8449
8450     r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
8451     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8452
8453     r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
8454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8455
8456     r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
8457     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8458
8459     r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
8460     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8461
8462     r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
8463     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8464
8465     r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
8466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8467
8468     r = create_reglocator_table(hdb);
8469     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8470
8471     type = msidbLocatorTypeRawValue;
8472     if (is_64bit)
8473         type |= msidbLocatorType64bit;
8474
8475     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
8476     r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
8477     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8478
8479     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
8480     r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
8481     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8482
8483     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
8484     r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
8485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8486
8487     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8488     r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
8489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8490
8491     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
8492     r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
8493     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8494
8495     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
8496     r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
8497     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8498
8499     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
8500     r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
8501     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8502
8503     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
8504     r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
8505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8506
8507     type = msidbLocatorTypeFileName;
8508     if (is_64bit)
8509         type |= msidbLocatorType64bit;
8510
8511     /* HKLM, msidbLocatorTypeFileName, signature, file exists */
8512     r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
8513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8514
8515     /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
8516     r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
8517     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8518
8519     /* HKLM, msidbLocatorTypeFileName, no signature */
8520     r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
8521     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8522
8523     type = msidbLocatorTypeDirectory;
8524     if (is_64bit)
8525         type |= msidbLocatorType64bit;
8526
8527     /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
8528     r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
8529     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8530
8531     /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
8532     r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
8533     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8534
8535     /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
8536     r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
8537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8538
8539     type = msidbLocatorTypeRawValue;
8540     if (is_64bit)
8541         type |= msidbLocatorType64bit;
8542
8543     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
8544     r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
8545     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8546
8547     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
8548     r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
8549     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8550
8551     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
8552     r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
8553     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8554
8555     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
8556     r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
8557     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8558
8559     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
8560     r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
8561     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8562
8563     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
8564     r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
8565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8566
8567     type = msidbLocatorTypeFileName;
8568     if (is_64bit)
8569         type |= msidbLocatorType64bit;
8570
8571     /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
8572     r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
8573     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8574
8575     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
8576     r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
8577     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8578
8579     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
8580     r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
8581     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8582
8583     /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
8584     r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
8585     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8586
8587     /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
8588     r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
8589     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8590
8591     type = msidbLocatorTypeDirectory;
8592     if (is_64bit)
8593         type |= msidbLocatorType64bit;
8594
8595     /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
8596     r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
8597     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8598
8599     /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
8600     r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
8601     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8602
8603     /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
8604     r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
8605     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8606
8607     type = msidbLocatorTypeFileName;
8608     if (is_64bit)
8609         type |= msidbLocatorType64bit;
8610
8611     /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
8612     r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
8613     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8614
8615     /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
8616     r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
8617     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8618
8619     r = create_signature_table(hdb);
8620     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8621
8622     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
8623     r = add_signature_entry(hdb, str);
8624     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8625
8626     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
8627     r = add_signature_entry(hdb, str);
8628     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8629
8630     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
8631     r = add_signature_entry(hdb, str);
8632     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8633
8634     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8635     r = add_signature_entry(hdb, str);
8636     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8637
8638     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8639     r = add_signature_entry(hdb, str);
8640     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8641
8642     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
8643     r = add_signature_entry(hdb, str);
8644     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8645
8646     ptr = strrchr(CURR_DIR, '\\') + 1;
8647     sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
8648     r = add_signature_entry(hdb, path);
8649     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8650
8651     str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
8652     r = add_signature_entry(hdb, str);
8653     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8654
8655     str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
8656     r = add_signature_entry(hdb, str);
8657     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8658
8659     str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
8660     r = add_signature_entry(hdb, str);
8661     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8662
8663     r = package_from_db(hdb, &hpkg);
8664     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
8665
8666     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8667
8668     r = MsiDoAction(hpkg, "AppSearch");
8669     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8670
8671     size = MAX_PATH;
8672     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
8673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8674     ok(!lstrcmpA(prop, "regszdata"),
8675        "Expected \"regszdata\", got \"%s\"\n", prop);
8676
8677     size = MAX_PATH;
8678     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
8679     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8680     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
8681
8682     size = MAX_PATH;
8683     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
8684     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8685     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
8686
8687     size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
8688     if (size == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
8689     {
8690         /* Workaround for Win95 */
8691         CHAR tempbuf[1];
8692         size = ExpandEnvironmentStringsA("%PATH%", tempbuf, 0);
8693     }
8694     pathvar = HeapAlloc(GetProcessHeap(), 0, size);
8695     ExpandEnvironmentStringsA("%PATH%", pathvar, size);
8696
8697     size = 0;
8698     r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
8699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8700
8701     pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
8702     r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
8703     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8704     ok(!lstrcmpA(pathdata, pathvar),
8705        "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
8706
8707     HeapFree(GetProcessHeap(), 0, pathvar);
8708     HeapFree(GetProcessHeap(), 0, pathdata);
8709
8710     size = MAX_PATH;
8711     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
8712     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8713     ok(!lstrcmpA(prop,
8714        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
8715
8716     size = MAX_PATH;
8717     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
8718     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8719     todo_wine
8720     {
8721         ok(!memcmp(prop, "\0one\0two\0\0", 10),
8722            "Expected \"\\0one\\0two\\0\\0\"\n");
8723     }
8724
8725     size = MAX_PATH;
8726     lstrcpyA(path, "#xCDAB3412EF907856");
8727     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
8728     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8729     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8730
8731     size = MAX_PATH;
8732     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
8733     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8734     ok(!lstrcmpA(prop, "##regszdata"),
8735        "Expected \"##regszdata\", got \"%s\"\n", prop);
8736
8737     size = MAX_PATH;
8738     sprintf(path, "%s\\FileName1", CURR_DIR);
8739     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
8740     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8741     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8742
8743     size = MAX_PATH;
8744     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
8745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8746     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8747
8748     size = MAX_PATH;
8749     sprintf(path, "%s\\", CURR_DIR);
8750     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
8751     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8752     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8753
8754     size = MAX_PATH;
8755     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
8756     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8757     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8758
8759     size = MAX_PATH;
8760     sprintf(path, "%s\\", CURR_DIR);
8761     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
8762     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8763     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8764
8765     size = MAX_PATH;
8766     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
8767     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8768     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8769
8770     size = MAX_PATH;
8771     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
8772     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8773     ok(!lstrcmpA(prop, "regszdata"),
8774        "Expected \"regszdata\", got \"%s\"\n", prop);
8775
8776     size = MAX_PATH;
8777     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
8778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8779     ok(!lstrcmpA(prop, "regszdata"),
8780        "Expected \"regszdata\", got \"%s\"\n", prop);
8781
8782     if (users)
8783     {
8784         size = MAX_PATH;
8785         r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
8786         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8787         ok(!lstrcmpA(prop, "regszdata"),
8788            "Expected \"regszdata\", got \"%s\"\n", prop);
8789     }
8790
8791     size = MAX_PATH;
8792     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
8793     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8794     ok(!lstrcmpA(prop, "defvalue"),
8795        "Expected \"defvalue\", got \"%s\"\n", prop);
8796
8797     size = MAX_PATH;
8798     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
8799     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8800     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8801
8802     size = MAX_PATH;
8803     r = MsiGetPropertyA(hpkg, "SIGPROP20", 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     if (version)
8808     {
8809         size = MAX_PATH;
8810         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8811         r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
8812         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8813         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8814
8815         size = MAX_PATH;
8816         r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
8817         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8818         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8819
8820         size = MAX_PATH;
8821         sprintf(path, "%s\\FileName5.dll", CURR_DIR);
8822         r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
8823         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8824         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8825     }
8826
8827     size = MAX_PATH;
8828     lstrcpyA(path, CURR_DIR);
8829     ptr = strrchr(path, '\\') + 1;
8830     *ptr = '\0';
8831     r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
8832     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8833     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8834
8835     size = MAX_PATH;
8836     sprintf(path, "%s\\", CURR_DIR);
8837     r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
8838     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8839     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8840
8841     size = MAX_PATH;
8842     r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
8843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8844     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8845
8846     size = MAX_PATH;
8847     r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
8848     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8849     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8850
8851     size = MAX_PATH;
8852     r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
8853     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8854     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8855
8856     size = MAX_PATH;
8857     sprintf(path, "%s\\FileName1", CURR_DIR);
8858     r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
8859     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8860     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8861
8862     size = MAX_PATH;
8863     sprintf(path, "%s\\FileName1", CURR_DIR);
8864     r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
8865     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8866     if (space)
8867         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
8868     else
8869         todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
8870
8871     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
8872     RegDeleteValueA(hklm, "Value1");
8873     RegDeleteValueA(hklm, "Value2");
8874     RegDeleteValueA(hklm, "Value3");
8875     RegDeleteValueA(hklm, "Value4");
8876     RegDeleteValueA(hklm, "Value5");
8877     RegDeleteValueA(hklm, "Value6");
8878     RegDeleteValueA(hklm, "Value7");
8879     RegDeleteValueA(hklm, "Value8");
8880     RegDeleteValueA(hklm, "Value9");
8881     RegDeleteValueA(hklm, "Value10");
8882     RegDeleteValueA(hklm, "Value11");
8883     RegDeleteValueA(hklm, "Value12");
8884     RegDeleteValueA(hklm, "Value13");
8885     RegDeleteValueA(hklm, "Value14");
8886     RegDeleteValueA(hklm, "Value15");
8887     RegDeleteValueA(hklm, "Value16");
8888     RegDeleteValueA(hklm, "Value17");
8889     RegDeleteKey(hklm, "");
8890     RegCloseKey(hklm);
8891
8892     RegDeleteValueA(classes, "Value1");
8893     RegDeleteKeyA(classes, "");
8894     RegCloseKey(classes);
8895
8896     RegDeleteValueA(hkcu, "Value1");
8897     RegDeleteKeyA(hkcu, "");
8898     RegCloseKey(hkcu);
8899
8900     RegDeleteValueA(users, "Value1");
8901     RegDeleteKeyA(users, "");
8902     RegCloseKey(users);
8903
8904     DeleteFileA("FileName1");
8905     DeleteFileA("FileName3.dll");
8906     DeleteFileA("FileName4.dll");
8907     DeleteFileA("FileName5.dll");
8908     MsiCloseHandle(hpkg);
8909     DeleteFileA(msifile);
8910 }
8911
8912 static void delete_win_ini(LPCSTR file)
8913 {
8914     CHAR path[MAX_PATH];
8915
8916     GetWindowsDirectoryA(path, MAX_PATH);
8917     lstrcatA(path, "\\");
8918     lstrcatA(path, file);
8919
8920     DeleteFileA(path);
8921 }
8922
8923 static void test_appsearch_inilocator(void)
8924 {
8925     MSIHANDLE hpkg, hdb;
8926     CHAR path[MAX_PATH];
8927     CHAR prop[MAX_PATH];
8928     BOOL version;
8929     LPCSTR str;
8930     LPSTR ptr;
8931     DWORD size;
8932     UINT r;
8933
8934     version = TRUE;
8935     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
8936         version = FALSE;
8937
8938     DeleteFileA("test.dll");
8939
8940     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
8941
8942     create_test_file("FileName1");
8943     sprintf(path, "%s\\FileName1", CURR_DIR);
8944     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
8945
8946     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
8947
8948     sprintf(path, "%s\\IDontExist", CURR_DIR);
8949     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
8950
8951     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8952     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
8953     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
8954
8955     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
8956     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
8957     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
8958
8959     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
8960     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
8961     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
8962
8963     hdb = create_package_db();
8964     ok(hdb, "Expected a valid database handle\n");
8965
8966     r = create_appsearch_table(hdb);
8967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8968
8969     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
8970     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8971
8972     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
8973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8974
8975     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
8976     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8977
8978     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
8979     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8980
8981     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
8982     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8983
8984     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
8985     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8986
8987     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
8988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8989
8990     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
8991     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8992
8993     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
8994     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8995
8996     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
8997     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8998
8999     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
9000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9001
9002     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
9003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9004
9005     r = create_inilocator_table(hdb);
9006     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9007
9008     /* msidbLocatorTypeRawValue, field 1 */
9009     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
9010     r = add_inilocator_entry(hdb, str);
9011     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9012
9013     /* msidbLocatorTypeRawValue, field 2 */
9014     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
9015     r = add_inilocator_entry(hdb, str);
9016     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9017
9018     /* msidbLocatorTypeRawValue, entire field */
9019     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
9020     r = add_inilocator_entry(hdb, str);
9021     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9022
9023     /* msidbLocatorTypeFile */
9024     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
9025     r = add_inilocator_entry(hdb, str);
9026     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9027
9028     /* msidbLocatorTypeDirectory, file */
9029     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
9030     r = add_inilocator_entry(hdb, str);
9031     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9032
9033     /* msidbLocatorTypeDirectory, directory */
9034     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
9035     r = add_inilocator_entry(hdb, str);
9036     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9037
9038     /* msidbLocatorTypeFile, file, no signature */
9039     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
9040     r = add_inilocator_entry(hdb, str);
9041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9042
9043     /* msidbLocatorTypeFile, dir, no signature */
9044     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
9045     r = add_inilocator_entry(hdb, str);
9046     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9047
9048     /* msidbLocatorTypeFile, file does not exist */
9049     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
9050     r = add_inilocator_entry(hdb, str);
9051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9052
9053     /* msidbLocatorTypeFile, signature with version */
9054     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
9055     r = add_inilocator_entry(hdb, str);
9056     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9057
9058     /* msidbLocatorTypeFile, signature with version, ver > max */
9059     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
9060     r = add_inilocator_entry(hdb, str);
9061     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9062
9063     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
9064     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
9065     r = add_inilocator_entry(hdb, str);
9066     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9067
9068     r = create_signature_table(hdb);
9069     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9070
9071     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
9072     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9073
9074     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
9075     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9076
9077     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9078     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9079
9080     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9081     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9082
9083     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
9084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9085
9086     r = package_from_db(hdb, &hpkg);
9087     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9088     {
9089         skip("Not enough rights to perform tests\n");
9090         goto error;
9091     }
9092     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9093
9094     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9095
9096     r = MsiDoAction(hpkg, "AppSearch");
9097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9098
9099     size = MAX_PATH;
9100     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9101     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9102     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
9103
9104     size = MAX_PATH;
9105     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9106     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9107     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
9108
9109     size = MAX_PATH;
9110     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9111     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9112     ok(!lstrcmpA(prop, "keydata,field2"),
9113        "Expected \"keydata,field2\", got \"%s\"\n", prop);
9114
9115     size = MAX_PATH;
9116     sprintf(path, "%s\\FileName1", CURR_DIR);
9117     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9118     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9119     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9120
9121     size = MAX_PATH;
9122     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9123     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9124     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9125
9126     size = MAX_PATH;
9127     sprintf(path, "%s\\", CURR_DIR);
9128     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9129     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9130     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9131
9132     size = MAX_PATH;
9133     sprintf(path, "%s\\", CURR_DIR);
9134     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9135     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9136     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9137
9138     size = MAX_PATH;
9139     lstrcpyA(path, CURR_DIR);
9140     ptr = strrchr(path, '\\');
9141     *(ptr + 1) = '\0';
9142     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9143     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9144     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9145
9146     size = MAX_PATH;
9147     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9148     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9149     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9150
9151     if (version)
9152     {
9153         size = MAX_PATH;
9154         sprintf(path, "%s\\FileName2.dll", CURR_DIR);
9155         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9156         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9157         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9158
9159         size = MAX_PATH;
9160         r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9161         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9162         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9163
9164         size = MAX_PATH;
9165         sprintf(path, "%s\\FileName4.dll", CURR_DIR);
9166         r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
9167         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9168         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9169     }
9170
9171     MsiCloseHandle(hpkg);
9172
9173 error:
9174     delete_win_ini("IniFile.ini");
9175     DeleteFileA("FileName1");
9176     DeleteFileA("FileName2.dll");
9177     DeleteFileA("FileName3.dll");
9178     DeleteFileA("FileName4.dll");
9179     DeleteFileA(msifile);
9180 }
9181
9182 /*
9183  * MSI AppSearch action on DrLocator table always returns absolute paths.
9184  * If a relative path was set, it returns the first absolute path that
9185  * matches or an empty string if it didn't find anything.
9186  * This helper function replicates this behaviour.
9187  */
9188 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
9189 {
9190     int i, size;
9191     DWORD attr, drives;
9192
9193     size = lstrlenA(relative);
9194     drives = GetLogicalDrives();
9195     lstrcpyA(absolute, "A:\\");
9196     for (i = 0; i < 26; absolute[0] = '\0', i++)
9197     {
9198         if (!(drives & (1 << i)))
9199             continue;
9200
9201         absolute[0] = 'A' + i;
9202         if (GetDriveType(absolute) != DRIVE_FIXED)
9203             continue;
9204
9205         lstrcpynA(absolute + 3, relative, size + 1);
9206         attr = GetFileAttributesA(absolute);
9207         if (attr != INVALID_FILE_ATTRIBUTES &&
9208             (attr & FILE_ATTRIBUTE_DIRECTORY))
9209         {
9210             if (absolute[3 + size - 1] != '\\')
9211                 lstrcatA(absolute, "\\");
9212             break;
9213         }
9214         absolute[3] = '\0';
9215     }
9216 }
9217
9218 static void test_appsearch_drlocator(void)
9219 {
9220     MSIHANDLE hpkg, hdb;
9221     CHAR path[MAX_PATH];
9222     CHAR prop[MAX_PATH];
9223     BOOL version;
9224     LPCSTR str;
9225     DWORD size;
9226     UINT r;
9227
9228     version = TRUE;
9229     if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
9230         version = FALSE;
9231
9232     DeleteFileA("test.dll");
9233
9234     create_test_file("FileName1");
9235     CreateDirectoryA("one", NULL);
9236     CreateDirectoryA("one\\two", NULL);
9237     CreateDirectoryA("one\\two\\three", NULL);
9238     create_test_file("one\\two\\three\\FileName2");
9239     CreateDirectoryA("another", NULL);
9240     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9241     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
9242     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
9243
9244     hdb = create_package_db();
9245     ok(hdb, "Expected a valid database handle\n");
9246
9247     r = create_appsearch_table(hdb);
9248     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9249
9250     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
9251     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9252
9253     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
9254     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9255
9256     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
9257     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9258
9259     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
9260     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9261
9262     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
9263     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9264
9265     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
9266     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9267
9268     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
9269     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9270
9271     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
9272     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9273
9274     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
9275     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9276
9277     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
9278     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9279
9280     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
9281     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9282
9283     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
9284     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9285
9286     r = create_drlocator_table(hdb);
9287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9288
9289     /* no parent, full path, depth 0, signature */
9290     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
9291     r = add_drlocator_entry(hdb, path);
9292     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9293
9294     /* no parent, full path, depth 0, no signature */
9295     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
9296     r = add_drlocator_entry(hdb, path);
9297     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9298
9299     /* no parent, relative path, depth 0, no signature */
9300     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
9301     r = add_drlocator_entry(hdb, path);
9302     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9303
9304     /* no parent, full path, depth 2, signature */
9305     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
9306     r = add_drlocator_entry(hdb, path);
9307     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9308
9309     /* no parent, full path, depth 3, signature */
9310     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
9311     r = add_drlocator_entry(hdb, path);
9312     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9313
9314     /* no parent, full path, depth 1, signature is dir */
9315     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
9316     r = add_drlocator_entry(hdb, path);
9317     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9318
9319     /* parent is in DrLocator, relative path, depth 0, signature */
9320     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
9321     r = add_drlocator_entry(hdb, path);
9322     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9323
9324     /* no parent, full path, depth 0, signature w/ version */
9325     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
9326     r = add_drlocator_entry(hdb, path);
9327     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9328
9329     /* no parent, full path, depth 0, signature w/ version, ver > max */
9330     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
9331     r = add_drlocator_entry(hdb, path);
9332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9333
9334     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
9335     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
9336     r = add_drlocator_entry(hdb, path);
9337     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9338
9339     /* no parent, relative empty path, depth 0, no signature */
9340     sprintf(path, "'NewSignature11', '', '', 0");
9341     r = add_drlocator_entry(hdb, path);
9342     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9343
9344     r = create_reglocator_table(hdb);
9345     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9346
9347     /* parent */
9348     r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
9349     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9350
9351     /* parent is in RegLocator, no path, depth 0, no signature */
9352     sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
9353     r = add_drlocator_entry(hdb, path);
9354     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9355
9356     r = create_signature_table(hdb);
9357     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9358
9359     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
9360     r = add_signature_entry(hdb, str);
9361     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9362
9363     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
9364     r = add_signature_entry(hdb, str);
9365     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9366
9367     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
9368     r = add_signature_entry(hdb, str);
9369     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9370
9371     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
9372     r = add_signature_entry(hdb, str);
9373     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9374
9375     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
9376     r = add_signature_entry(hdb, str);
9377     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9378
9379     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9380     r = add_signature_entry(hdb, str);
9381     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9382
9383     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9384     r = add_signature_entry(hdb, str);
9385     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9386
9387     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
9388     r = add_signature_entry(hdb, str);
9389     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9390
9391     r = package_from_db(hdb, &hpkg);
9392     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9393     {
9394         skip("Not enough rights to perform tests\n");
9395         goto error;
9396     }
9397     ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
9398
9399     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9400
9401     r = MsiDoAction(hpkg, "AppSearch");
9402     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9403
9404     size = MAX_PATH;
9405     sprintf(path, "%s\\FileName1", CURR_DIR);
9406     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
9407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9408     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9409
9410     size = MAX_PATH;
9411     sprintf(path, "%s\\", CURR_DIR);
9412     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
9413     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9414     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9415
9416     size = MAX_PATH;
9417     search_absolute_directory(path, CURR_DIR + 3);
9418     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
9419     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9420     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9421
9422     size = MAX_PATH;
9423     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
9424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9425     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9426
9427     size = MAX_PATH;
9428     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9429     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
9430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9431     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9432
9433     size = MAX_PATH;
9434     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
9435     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9436     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9437
9438     size = MAX_PATH;
9439     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
9440     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
9441     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9442     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9443
9444     if (version)
9445     {
9446         size = MAX_PATH;
9447         sprintf(path, "%s\\FileName3.dll", CURR_DIR);
9448         r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
9449         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9450         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9451
9452         size = MAX_PATH;
9453         r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
9454         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9455         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9456
9457         size = MAX_PATH;
9458         r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
9459         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9460         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
9461     }
9462
9463     size = MAX_PATH;
9464     search_absolute_directory(path, "");
9465     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
9466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9467     ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
9468
9469     size = MAX_PATH;
9470     strcpy(path, "c:\\");
9471     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
9472     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9473     ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
9474
9475     MsiCloseHandle(hpkg);
9476
9477 error:
9478     DeleteFileA("FileName1");
9479     DeleteFileA("FileName3.dll");
9480     DeleteFileA("FileName4.dll");
9481     DeleteFileA("FileName5.dll");
9482     DeleteFileA("one\\two\\three\\FileName2");
9483     RemoveDirectoryA("one\\two\\three");
9484     RemoveDirectoryA("one\\two");
9485     RemoveDirectoryA("one");
9486     RemoveDirectoryA("another");
9487     DeleteFileA(msifile);
9488 }
9489
9490 static void test_featureparents(void)
9491 {
9492     MSIHANDLE hpkg;
9493     UINT r;
9494     MSIHANDLE hdb;
9495     INSTALLSTATE state, action;
9496
9497     hdb = create_package_db();
9498     ok ( hdb, "failed to create package database\n" );
9499
9500     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
9501     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
9502
9503     r = create_feature_table( hdb );
9504     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
9505
9506     r = create_component_table( hdb );
9507     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
9508
9509     r = create_feature_components_table( hdb );
9510     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
9511
9512     r = create_file_table( hdb );
9513     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
9514
9515     /* msidbFeatureAttributesFavorLocal */
9516     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
9517     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9518
9519     /* msidbFeatureAttributesFavorSource */
9520     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
9521     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9522
9523     /* msidbFeatureAttributesFavorLocal */
9524     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
9525     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9526
9527     /* msidbFeatureAttributesUIDisallowAbsent */
9528     r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
9529     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9530
9531     /* disabled because of install level */
9532     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
9533     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9534
9535     /* child feature of disabled feature */
9536     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
9537     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
9538
9539     /* component of disabled feature (install level) */
9540     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
9541     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9542
9543     /* component of disabled child feature (install level) */
9544     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
9545     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9546
9547     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9548     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
9549     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9550
9551     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9552     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
9553     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9554
9555     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9556     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
9557     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9558
9559     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
9560     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
9561     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9562
9563     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
9564     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
9565     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9566
9567     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
9568     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
9569     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9570
9571     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
9572     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
9573     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9574
9575     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
9576     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
9577     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
9578
9579     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
9580     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
9581
9582     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
9583     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9584
9585     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
9586     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9587
9588     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
9589     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9590
9591     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
9592     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9593
9594     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
9595     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9596
9597     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
9598     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9599
9600     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
9601     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9602
9603     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
9604     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9605
9606     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
9607     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9608
9609     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
9610     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9611
9612     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
9613     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9614
9615     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
9616     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9617
9618     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
9619     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9620
9621     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
9622     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9623
9624     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
9625     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9626
9627     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
9628     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9629
9630     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
9631     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
9632
9633     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
9634     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9635
9636     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
9637     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9638
9639     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
9640     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9641
9642     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
9643     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9644
9645     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
9646     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9647
9648     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
9649     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9650
9651     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
9652     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9653
9654     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
9655     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9656
9657     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
9658     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9659
9660     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
9661     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9662
9663     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
9664     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
9665
9666     r = package_from_db( hdb, &hpkg );
9667     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9668     {
9669         skip("Not enough rights to perform tests\n");
9670         DeleteFile(msifile);
9671         return;
9672     }
9673     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9674
9675     MsiCloseHandle( hdb );
9676
9677     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9678
9679     r = MsiDoAction( hpkg, "CostInitialize");
9680     ok( r == ERROR_SUCCESS, "cost init failed\n");
9681
9682     r = MsiDoAction( hpkg, "FileCost");
9683     ok( r == ERROR_SUCCESS, "file cost failed\n");
9684
9685     r = MsiDoAction( hpkg, "CostFinalize");
9686     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
9687
9688     state = 0xdeadbee;
9689     action = 0xdeadbee;
9690     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9691     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9692     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9693     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9694
9695     state = 0xdeadbee;
9696     action = 0xdeadbee;
9697     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9698     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9699     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9700     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
9701
9702     state = 0xdeadbee;
9703     action = 0xdeadbee;
9704     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9705     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9706     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9707     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9708
9709     state = 0xdeadbee;
9710     action = 0xdeadbee;
9711     r = MsiGetFeatureState(hpkg, "lyra", &state, &action);
9712     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9713     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9714     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9715
9716     state = 0xdeadbee;
9717     action = 0xdeadbee;
9718     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
9719     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9720     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9721     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9722
9723     state = 0xdeadbee;
9724     action = 0xdeadbee;
9725     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
9726     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9727     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
9728     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
9729
9730     state = 0xdeadbee;
9731     action = 0xdeadbee;
9732     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9733     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9734     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
9735     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
9736
9737     state = 0xdeadbee;
9738     action = 0xdeadbee;
9739     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9740     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9741     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9742     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9743
9744     state = 0xdeadbee;
9745     action = 0xdeadbee;
9746     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9747     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9748     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9749     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9750
9751     state = 0xdeadbee;
9752     action = 0xdeadbee;
9753     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9754     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9755     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9756     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9757
9758     state = 0xdeadbee;
9759     action = 0xdeadbee;
9760     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9761     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9762     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9763     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9764
9765     state = 0xdeadbee;
9766     action = 0xdeadbee;
9767     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9768     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9769     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9770     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
9771
9772     state = 0xdeadbee;
9773     action = 0xdeadbee;
9774     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9775     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9776     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9777     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
9778
9779     state = 0xdeadbee;
9780     action = 0xdeadbee;
9781     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9782     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9783     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9784     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
9785
9786     state = 0xdeadbee;
9787     action = 0xdeadbee;
9788     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9789     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9790     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9791     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
9792
9793     state = 0xdeadbee;
9794     action = 0xdeadbee;
9795     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9796     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9797     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9798     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9799
9800     state = 0xdeadbee;
9801     action = 0xdeadbee;
9802     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9803     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9804     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9805     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9806
9807     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
9808     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9809
9810     r = MsiSetFeatureState(hpkg, "lyra", INSTALLSTATE_ABSENT);
9811     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
9812
9813     r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
9814     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
9815
9816     state = 0xdeadbee;
9817     action = 0xdeadbee;
9818     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
9819     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9820     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
9821     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
9822
9823     state = 0xdeadbee;
9824     action = 0xdeadbee;
9825     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
9826     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9827     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
9828     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
9829
9830     state = 0xdeadbee;
9831     action = 0xdeadbee;
9832     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
9833     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9834     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
9835     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
9836
9837     state = 0xdeadbee;
9838     action = 0xdeadbee;
9839     r = MsiGetFeatureState(hpkg, "lyra", &state, &action);
9840     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9841     ok( state == INSTALLSTATE_ABSENT, "Expected lyra INSTALLSTATE_ABSENT, got %d\n", state);
9842     ok( action == INSTALLSTATE_ABSENT, "Expected lyra INSTALLSTATE_ABSENT, got %d\n", action);
9843
9844     state = 0xdeadbee;
9845     action = 0xdeadbee;
9846     r = MsiGetComponentState(hpkg, "leo", &state, &action);
9847     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9848     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
9849     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
9850
9851     state = 0xdeadbee;
9852     action = 0xdeadbee;
9853     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
9854     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9855     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
9856     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
9857
9858     state = 0xdeadbee;
9859     action = 0xdeadbee;
9860     r = MsiGetComponentState(hpkg, "libra", &state, &action);
9861     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9862     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
9863     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
9864
9865     state = 0xdeadbee;
9866     action = 0xdeadbee;
9867     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
9868     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9869     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
9870     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
9871
9872     state = 0xdeadbee;
9873     action = 0xdeadbee;
9874     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
9875     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9876     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
9877     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
9878
9879     state = 0xdeadbee;
9880     action = 0xdeadbee;
9881     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
9882     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9883     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
9884     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
9885
9886     state = 0xdeadbee;
9887     action = 0xdeadbee;
9888     r = MsiGetComponentState(hpkg, "canis", &state, &action);
9889     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9890     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
9891     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
9892
9893     state = 0xdeadbee;
9894     action = 0xdeadbee;
9895     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
9896     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9897     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
9898     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
9899
9900     state = 0xdeadbee;
9901     action = 0xdeadbee;
9902     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
9903     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9904     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
9905     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
9906
9907     state = 0xdeadbee;
9908     action = 0xdeadbee;
9909     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
9910     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9911     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
9912     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
9913
9914     state = 0xdeadbee;
9915     action = 0xdeadbee;
9916     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
9917     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
9918     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
9919     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
9920     
9921     MsiCloseHandle(hpkg);
9922     DeleteFileA(msifile);
9923 }
9924
9925 static void test_installprops(void)
9926 {
9927     MSIHANDLE hpkg, hdb;
9928     CHAR path[MAX_PATH], buf[MAX_PATH];
9929     DWORD size, type;
9930     LANGID langid;
9931     HKEY hkey1, hkey2;
9932     int res;
9933     UINT r;
9934     REGSAM access = KEY_ALL_ACCESS;
9935     SYSTEM_INFO si;
9936
9937     if (is_wow64)
9938         access |= KEY_WOW64_64KEY;
9939
9940     GetCurrentDirectory(MAX_PATH, path);
9941     lstrcat(path, "\\");
9942     lstrcat(path, msifile);
9943
9944     hdb = create_package_db();
9945     ok( hdb, "failed to create database\n");
9946
9947     r = package_from_db(hdb, &hpkg);
9948     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9949     {
9950         skip("Not enough rights to perform tests\n");
9951         DeleteFile(msifile);
9952         return;
9953     }
9954     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
9955
9956     MsiCloseHandle(hdb);
9957
9958     size = MAX_PATH;
9959     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
9960     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9961     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9962
9963     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
9964     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
9965
9966     size = MAX_PATH;
9967     type = REG_SZ;
9968     *path = '\0';
9969     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9970     {
9971         size = MAX_PATH;
9972         type = REG_SZ;
9973         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
9974     }
9975
9976     /* win9x doesn't set this */
9977     if (*path)
9978     {
9979         size = MAX_PATH;
9980         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
9981         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
9982         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
9983     }
9984
9985     size = MAX_PATH;
9986     type = REG_SZ;
9987     *path = '\0';
9988     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
9989     {
9990         size = MAX_PATH;
9991         type = REG_SZ;
9992         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
9993     }
9994
9995     if (*path)
9996     {
9997         size = MAX_PATH;
9998         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
9999         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10000         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
10001     }
10002
10003     size = MAX_PATH;
10004     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
10005     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10006     trace("VersionDatabase = %s\n", buf);
10007
10008     size = MAX_PATH;
10009     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
10010     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10011     trace("VersionMsi = %s\n", buf);
10012
10013     size = MAX_PATH;
10014     r = MsiGetProperty(hpkg, "Date", buf, &size);
10015     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10016     trace("Date = %s\n", buf);
10017
10018     size = MAX_PATH;
10019     r = MsiGetProperty(hpkg, "Time", buf, &size);
10020     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10021     trace("Time = %s\n", buf);
10022
10023     size = MAX_PATH;
10024     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
10025     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10026     trace("PackageCode = %s\n", buf);
10027
10028     langid = GetUserDefaultLangID();
10029     sprintf(path, "%d", langid);
10030
10031     size = MAX_PATH;
10032     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
10033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
10034     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
10035
10036     res = GetSystemMetrics(SM_CXSCREEN);
10037     size = MAX_PATH;
10038     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
10039     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
10040
10041     res = GetSystemMetrics(SM_CYSCREEN);
10042     size = MAX_PATH;
10043     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
10044     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
10045
10046     if (pGetSystemInfo && pSHGetFolderPathA)
10047     {
10048         pGetSystemInfo(&si);
10049         if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
10050         {
10051             buf[0] = 0;
10052             size = MAX_PATH;
10053             r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10054             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10055             ok(buf[0], "property not set\n");
10056
10057             buf[0] = 0;
10058             size = MAX_PATH;
10059             r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10060             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10061             ok(buf[0], "property not set\n");
10062
10063             buf[0] = 0;
10064             size = MAX_PATH;
10065             r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10066             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10067             GetSystemDirectoryA(path, MAX_PATH);
10068             if (size) buf[size - 1] = 0;
10069             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10070
10071             buf[0] = 0;
10072             size = MAX_PATH;
10073             r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10074             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10075             pGetSystemWow64DirectoryA(path, MAX_PATH);
10076             if (size) buf[size - 1] = 0;
10077             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10078
10079             buf[0] = 0;
10080             size = MAX_PATH;
10081             r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
10082             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10083             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
10084             if (size) buf[size - 1] = 0;
10085             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10086
10087             buf[0] = 0;
10088             size = MAX_PATH;
10089             r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10090             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10091             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
10092             if (size) buf[size - 1] = 0;
10093             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10094
10095             buf[0] = 0;
10096             size = MAX_PATH;
10097             r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
10098             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10099             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
10100             if (size) buf[size - 1] = 0;
10101             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10102
10103             buf[0] = 0;
10104             size = MAX_PATH;
10105             r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10106             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10107             pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
10108             if (size) buf[size - 1] = 0;
10109             ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10110
10111             buf[0] = 0;
10112             size = MAX_PATH;
10113             r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10114             ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10115             ok(buf[0], "property not set\n");
10116         }
10117         else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
10118         {
10119             if (!is_wow64)
10120             {
10121                 buf[0] = 0;
10122                 size = MAX_PATH;
10123                 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10124                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10125                 ok(!buf[0], "property set\n");
10126
10127                 buf[0] = 0;
10128                 size = MAX_PATH;
10129                 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10130                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10131                 ok(!buf[0], "property set\n");
10132
10133                 buf[0] = 0;
10134                 size = MAX_PATH;
10135                 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10136                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10137                 ok(!buf[0], "property set\n");
10138
10139                 buf[0] = 0;
10140                 size = MAX_PATH;
10141                 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10142                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10143                 GetSystemDirectoryA(path, MAX_PATH);
10144                 if (size) buf[size - 1] = 0;
10145                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10146
10147                 buf[0] = 0;
10148                 size = MAX_PATH;
10149                 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
10150                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10151                 ok(!buf[0], "property set\n");
10152
10153                 buf[0] = 0;
10154                 size = MAX_PATH;
10155                 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10156                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10157                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
10158                 if (size) buf[size - 1] = 0;
10159                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10160
10161                 buf[0] = 0;
10162                 size = MAX_PATH;
10163                 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
10164                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10165                 ok(!buf[0], "property set\n");
10166
10167                 buf[0] = 0;
10168                 size = MAX_PATH;
10169                 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10170                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10171                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
10172                 if (size) buf[size - 1] = 0;
10173                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10174
10175                 buf[0] = 0;
10176                 size = MAX_PATH;
10177                 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10178                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10179                 ok(!buf[0], "property set\n");
10180             }
10181             else
10182             {
10183                 buf[0] = 0;
10184                 size = MAX_PATH;
10185                 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
10186                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10187                 ok(buf[0], "property not set\n");
10188
10189                 buf[0] = 0;
10190                 size = MAX_PATH;
10191                 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
10192                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10193                 ok(buf[0], "property not set\n");
10194
10195                 buf[0] = 0;
10196                 size = MAX_PATH;
10197                 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
10198                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10199                 GetSystemDirectoryA(path, MAX_PATH);
10200                 if (size) buf[size - 1] = 0;
10201                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10202
10203                 buf[0] = 0;
10204                 size = MAX_PATH;
10205                 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
10206                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10207                 pGetSystemWow64DirectoryA(path, MAX_PATH);
10208                 if (size) buf[size - 1] = 0;
10209                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10210
10211                 buf[0] = 0;
10212                 size = MAX_PATH;
10213                 r = MsiGetProperty(hpkg, "ProgramFilesFolder64", buf, &size);
10214                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10215                 ok(!buf[0], "property set\n");
10216
10217                 buf[0] = 0;
10218                 size = MAX_PATH;
10219                 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
10220                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10221                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
10222                 if (size) buf[size - 1] = 0;
10223                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10224
10225                 buf[0] = 0;
10226                 size = MAX_PATH;
10227                 r = MsiGetProperty(hpkg, "CommonFilesFolder64", buf, &size);
10228                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10229                 ok(!buf[0], "property set\n");
10230
10231                 buf[0] = 0;
10232                 size = MAX_PATH;
10233                 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
10234                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10235                 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
10236                 if (size) buf[size - 1] = 0;
10237                 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
10238
10239                 buf[0] = 0;
10240                 size = MAX_PATH;
10241                 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
10242                 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
10243                 ok(buf[0], "property not set\n");
10244             }
10245         }
10246     }
10247
10248     CloseHandle(hkey1);
10249     CloseHandle(hkey2);
10250     MsiCloseHandle(hpkg);
10251     DeleteFile(msifile);
10252 }
10253
10254 static void test_launchconditions(void)
10255 {
10256     MSIHANDLE hpkg;
10257     MSIHANDLE hdb;
10258     UINT r;
10259
10260     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10261
10262     hdb = create_package_db();
10263     ok( hdb, "failed to create package database\n" );
10264
10265     r = create_launchcondition_table( hdb );
10266     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
10267
10268     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
10269     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
10270
10271     /* invalid condition */
10272     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
10273     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
10274
10275     r = package_from_db( hdb, &hpkg );
10276     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10277     {
10278         skip("Not enough rights to perform tests\n");
10279         DeleteFile(msifile);
10280         return;
10281     }
10282     ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
10283
10284     MsiCloseHandle( hdb );
10285
10286     r = MsiSetProperty( hpkg, "X", "1" );
10287     ok( r == ERROR_SUCCESS, "failed to set property\n" );
10288
10289     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10290
10291     /* invalid conditions are ignored */
10292     r = MsiDoAction( hpkg, "LaunchConditions" );
10293     ok( r == ERROR_SUCCESS, "cost init failed\n" );
10294
10295     /* verify LaunchConditions still does some verification */
10296     r = MsiSetProperty( hpkg, "X", "2" );
10297     ok( r == ERROR_SUCCESS, "failed to set property\n" );
10298
10299     r = MsiDoAction( hpkg, "LaunchConditions" );
10300     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
10301
10302     MsiCloseHandle( hpkg );
10303     DeleteFile( msifile );
10304 }
10305
10306 static void test_ccpsearch(void)
10307 {
10308     MSIHANDLE hdb, hpkg;
10309     CHAR prop[MAX_PATH];
10310     DWORD size = MAX_PATH;
10311     UINT r;
10312
10313     hdb = create_package_db();
10314     ok(hdb, "failed to create package database\n");
10315
10316     r = create_ccpsearch_table(hdb);
10317     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10318
10319     r = add_ccpsearch_entry(hdb, "'CCP_random'");
10320     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10321
10322     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
10323     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10324
10325     r = create_reglocator_table(hdb);
10326     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10327
10328     r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
10329     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10330
10331     r = create_drlocator_table(hdb);
10332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10333
10334     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
10335     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10336
10337     r = create_signature_table(hdb);
10338     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10339
10340     r = package_from_db(hdb, &hpkg);
10341     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10342     {
10343         skip("Not enough rights to perform tests\n");
10344         DeleteFile(msifile);
10345         return;
10346     }
10347     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10348
10349     MsiCloseHandle(hdb);
10350
10351     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10352
10353     r = MsiDoAction(hpkg, "CCPSearch");
10354     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10355
10356     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
10357     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10358     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
10359
10360     MsiCloseHandle(hpkg);
10361     DeleteFileA(msifile);
10362 }
10363
10364 static void test_complocator(void)
10365 {
10366     MSIHANDLE hdb, hpkg;
10367     UINT r;
10368     CHAR prop[MAX_PATH];
10369     CHAR expected[MAX_PATH];
10370     DWORD size = MAX_PATH;
10371
10372     hdb = create_package_db();
10373     ok(hdb, "failed to create package database\n");
10374
10375     r = create_appsearch_table(hdb);
10376     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10377
10378     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
10379     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10380
10381     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
10382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10383
10384     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
10385     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10386
10387     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
10388     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10389
10390     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
10391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10392
10393     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
10394     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10395
10396     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
10397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10398
10399     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
10400     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10401
10402     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
10403     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10404
10405     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
10406     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10407
10408     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
10409     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10410
10411     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
10412     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10413
10414     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
10415     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10416
10417     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
10418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10419
10420     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
10421     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10422
10423     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
10424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10425
10426     r = create_complocator_table(hdb);
10427     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10428
10429     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
10430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10431
10432     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
10433     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10434
10435     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
10436     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10437
10438     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
10439     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10440
10441     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
10442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10443
10444     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
10445     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10446
10447     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
10448     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10449
10450     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
10451     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10452
10453     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
10454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10455
10456     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
10457     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10458
10459     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
10460     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10461
10462     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
10463     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10464
10465     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
10466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10467
10468     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
10469     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10470
10471     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
10472     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10473
10474     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
10475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10476
10477     r = create_signature_table(hdb);
10478     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10479
10480     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
10481     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10482
10483     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
10484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10485
10486     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
10487     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10488
10489     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
10490     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10491
10492     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
10493     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10494
10495     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
10496     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10497
10498     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
10499     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10500
10501     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
10502     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10503
10504     r = package_from_db(hdb, &hpkg);
10505     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10506     {
10507         skip("Not enough rights to perform tests\n");
10508         DeleteFile(msifile);
10509         return;
10510     }
10511     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10512
10513     MsiCloseHandle(hdb);
10514
10515     create_test_file("abelisaurus");
10516     create_test_file("bactrosaurus");
10517     create_test_file("camelotia");
10518     create_test_file("diclonius");
10519     create_test_file("echinodon");
10520     create_test_file("falcarius");
10521     create_test_file("gallimimus");
10522     create_test_file("hagryphus");
10523     CreateDirectoryA("iguanodon", NULL);
10524     CreateDirectoryA("jobaria", NULL);
10525     CreateDirectoryA("kakuru", NULL);
10526     CreateDirectoryA("labocania", NULL);
10527     CreateDirectoryA("megaraptor", NULL);
10528     CreateDirectoryA("neosodon", NULL);
10529     CreateDirectoryA("olorotitan", NULL);
10530     CreateDirectoryA("pantydraco", NULL);
10531
10532     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
10533                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
10534     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
10535                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
10536     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
10537                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
10538     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
10539                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
10540     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
10541                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
10542     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
10543                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
10544     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
10545                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
10546     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
10547                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
10548
10549     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10550
10551     r = MsiDoAction(hpkg, "AppSearch");
10552     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10553
10554     size = MAX_PATH;
10555     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
10556     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10557
10558     lstrcpyA(expected, CURR_DIR);
10559     lstrcatA(expected, "\\abelisaurus");
10560     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10561        "Expected %s or empty string, got %s\n", expected, prop);
10562
10563     size = MAX_PATH;
10564     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
10565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10566     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10567
10568     size = MAX_PATH;
10569     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
10570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10571     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10572
10573     size = MAX_PATH;
10574     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
10575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10576     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10577
10578     size = MAX_PATH;
10579     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
10580     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10581
10582     lstrcpyA(expected, CURR_DIR);
10583     lstrcatA(expected, "\\");
10584     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10585        "Expected %s or empty string, got %s\n", expected, prop);
10586
10587     size = MAX_PATH;
10588     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
10589     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10590     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10591
10592     size = MAX_PATH;
10593     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
10594     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10595     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10596
10597     size = MAX_PATH;
10598     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
10599     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10600     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10601
10602     size = MAX_PATH;
10603     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
10604     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10605     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10606
10607     size = MAX_PATH;
10608     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
10609     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10610     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10611
10612     size = MAX_PATH;
10613     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
10614     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10615     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10616
10617     size = MAX_PATH;
10618     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
10619     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10620     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10621
10622     size = MAX_PATH;
10623     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
10624     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10625
10626     lstrcpyA(expected, CURR_DIR);
10627     lstrcatA(expected, "\\");
10628     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10629        "Expected %s or empty string, got %s\n", expected, prop);
10630
10631     size = MAX_PATH;
10632     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
10633     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10634
10635     lstrcpyA(expected, CURR_DIR);
10636     lstrcatA(expected, "\\neosodon\\");
10637     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
10638        "Expected %s or empty string, got %s\n", expected, prop);
10639
10640     size = MAX_PATH;
10641     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
10642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10643     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10644
10645     size = MAX_PATH;
10646     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
10647     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10648     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
10649
10650     MsiCloseHandle(hpkg);
10651     DeleteFileA("abelisaurus");
10652     DeleteFileA("bactrosaurus");
10653     DeleteFileA("camelotia");
10654     DeleteFileA("diclonius");
10655     DeleteFileA("echinodon");
10656     DeleteFileA("falcarius");
10657     DeleteFileA("gallimimus");
10658     DeleteFileA("hagryphus");
10659     RemoveDirectoryA("iguanodon");
10660     RemoveDirectoryA("jobaria");
10661     RemoveDirectoryA("kakuru");
10662     RemoveDirectoryA("labocania");
10663     RemoveDirectoryA("megaraptor");
10664     RemoveDirectoryA("neosodon");
10665     RemoveDirectoryA("olorotitan");
10666     RemoveDirectoryA("pantydraco");
10667     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
10668                           MSIINSTALLCONTEXT_MACHINE, NULL);
10669     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
10670                           MSIINSTALLCONTEXT_MACHINE, NULL);
10671     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
10672                           MSIINSTALLCONTEXT_MACHINE, NULL);
10673     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
10674                           MSIINSTALLCONTEXT_MACHINE, NULL);
10675     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
10676                           MSIINSTALLCONTEXT_MACHINE, NULL);
10677     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
10678                           MSIINSTALLCONTEXT_MACHINE, NULL);
10679     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
10680                           MSIINSTALLCONTEXT_MACHINE, NULL);
10681     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
10682                           MSIINSTALLCONTEXT_MACHINE, NULL);
10683     DeleteFileA(msifile);
10684 }
10685
10686 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
10687 {
10688     MSIHANDLE summary;
10689     UINT r;
10690
10691     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
10692     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10693
10694     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
10695     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10696
10697     r = MsiSummaryInfoPersist(summary);
10698     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
10699
10700     MsiCloseHandle(summary);
10701 }
10702
10703 static void test_MsiGetSourcePath(void)
10704 {
10705     MSIHANDLE hdb, hpkg;
10706     CHAR path[MAX_PATH];
10707     CHAR cwd[MAX_PATH];
10708     CHAR subsrc[MAX_PATH];
10709     CHAR sub2[MAX_PATH];
10710     DWORD size;
10711     UINT r;
10712
10713     lstrcpyA(cwd, CURR_DIR);
10714     lstrcatA(cwd, "\\");
10715
10716     lstrcpyA(subsrc, cwd);
10717     lstrcatA(subsrc, "subsource");
10718     lstrcatA(subsrc, "\\");
10719
10720     lstrcpyA(sub2, subsrc);
10721     lstrcatA(sub2, "sub2");
10722     lstrcatA(sub2, "\\");
10723
10724     /* uncompressed source */
10725
10726     hdb = create_package_db();
10727     ok( hdb, "failed to create database\n");
10728
10729     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
10730
10731     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
10732     ok(r == S_OK, "failed\n");
10733
10734     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
10735     ok(r == S_OK, "failed\n");
10736
10737     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
10738     ok(r == S_OK, "failed\n");
10739
10740     r = MsiDatabaseCommit(hdb);
10741     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
10742
10743     r = package_from_db(hdb, &hpkg);
10744     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
10745     {
10746         skip("Not enough rights to perform tests\n");
10747         DeleteFile(msifile);
10748         return;
10749     }
10750     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
10751
10752     MsiCloseHandle(hdb);
10753
10754     /* invalid database handle */
10755     size = MAX_PATH;
10756     lstrcpyA(path, "kiwi");
10757     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
10758     ok(r == ERROR_INVALID_HANDLE,
10759        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
10760     ok(!lstrcmpA(path, "kiwi"),
10761        "Expected path to be unchanged, got \"%s\"\n", path);
10762     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10763
10764     /* NULL szFolder */
10765     size = MAX_PATH;
10766     lstrcpyA(path, "kiwi");
10767     r = MsiGetSourcePath(hpkg, NULL, path, &size);
10768     ok(r == ERROR_INVALID_PARAMETER,
10769        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10770     ok(!lstrcmpA(path, "kiwi"),
10771        "Expected path to be unchanged, got \"%s\"\n", path);
10772     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10773
10774     /* empty szFolder */
10775     size = MAX_PATH;
10776     lstrcpyA(path, "kiwi");
10777     r = MsiGetSourcePath(hpkg, "", path, &size);
10778     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10779     ok(!lstrcmpA(path, "kiwi"),
10780        "Expected path to be unchanged, got \"%s\"\n", path);
10781     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10782
10783     /* try TARGETDIR */
10784     size = MAX_PATH;
10785     lstrcpyA(path, "kiwi");
10786     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10787     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10788     ok(!lstrcmpA(path, "kiwi"),
10789        "Expected path to be unchanged, got \"%s\"\n", path);
10790     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10791
10792     size = MAX_PATH;
10793     lstrcpyA(path, "kiwi");
10794     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10796     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10797     ok(size == 0, "Expected 0, got %d\n", size);
10798
10799     size = MAX_PATH;
10800     lstrcpyA(path, "kiwi");
10801     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10802     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10803     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10804     ok(size == 0, "Expected 0, got %d\n", size);
10805
10806     /* try SourceDir */
10807     size = MAX_PATH;
10808     lstrcpyA(path, "kiwi");
10809     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10810     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10811     ok(!lstrcmpA(path, "kiwi"),
10812        "Expected path to be unchanged, got \"%s\"\n", path);
10813     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10814
10815     /* try SOURCEDIR */
10816     size = MAX_PATH;
10817     lstrcpyA(path, "kiwi");
10818     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10819     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10820     ok(!lstrcmpA(path, "kiwi"),
10821        "Expected path to be unchanged, got \"%s\"\n", path);
10822     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10823
10824     /* source path does not exist, but the property exists */
10825     size = MAX_PATH;
10826     lstrcpyA(path, "kiwi");
10827     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
10828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10829     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10830     ok(size == 0, "Expected 0, got %d\n", size);
10831
10832     size = MAX_PATH;
10833     lstrcpyA(path, "kiwi");
10834     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10835     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10836     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
10837     ok(size == 0, "Expected 0, got %d\n", size);
10838
10839     /* try SubDir */
10840     size = MAX_PATH;
10841     lstrcpyA(path, "kiwi");
10842     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10843     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10844     ok(!lstrcmpA(path, "kiwi"),
10845        "Expected path to be unchanged, got \"%s\"\n", path);
10846     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10847
10848     /* try SubDir2 */
10849     size = MAX_PATH;
10850     lstrcpyA(path, "kiwi");
10851     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10852     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10853     ok(!lstrcmpA(path, "kiwi"),
10854        "Expected path to be unchanged, got \"%s\"\n", path);
10855     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10856
10857     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
10858
10859     r = MsiDoAction(hpkg, "CostInitialize");
10860     ok(r == ERROR_SUCCESS, "cost init failed\n");
10861
10862     /* try TARGETDIR after CostInitialize */
10863     size = MAX_PATH;
10864     lstrcpyA(path, "kiwi");
10865     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10866     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10867     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10868     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10869
10870     /* try SourceDir after CostInitialize */
10871     size = MAX_PATH;
10872     lstrcpyA(path, "kiwi");
10873     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10874     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10875     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10876     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10877
10878     /* try SOURCEDIR after CostInitialize */
10879     size = MAX_PATH;
10880     lstrcpyA(path, "kiwi");
10881     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10882     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10883     ok(!lstrcmpA(path, "kiwi"),
10884        "Expected path to be unchanged, got \"%s\"\n", path);
10885     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10886
10887     /* source path does not exist, but the property exists */
10888     size = MAX_PATH;
10889     lstrcpyA(path, "kiwi");
10890     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10892     todo_wine
10893     {
10894         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10895         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10896     }
10897
10898     /* try SubDir after CostInitialize */
10899     size = MAX_PATH;
10900     lstrcpyA(path, "kiwi");
10901     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10902     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10903     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10904     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10905
10906     /* try SubDir2 after CostInitialize */
10907     size = MAX_PATH;
10908     lstrcpyA(path, "kiwi");
10909     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10910     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10911     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10912     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10913
10914     r = MsiDoAction(hpkg, "ResolveSource");
10915     ok(r == ERROR_SUCCESS, "file cost failed\n");
10916
10917     /* try TARGETDIR after ResolveSource */
10918     size = MAX_PATH;
10919     lstrcpyA(path, "kiwi");
10920     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10921     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10922     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10923     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10924
10925     /* try SourceDir after ResolveSource */
10926     size = MAX_PATH;
10927     lstrcpyA(path, "kiwi");
10928     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10930     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10931     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10932
10933     /* try SOURCEDIR after ResolveSource */
10934     size = MAX_PATH;
10935     lstrcpyA(path, "kiwi");
10936     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10937     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10938     ok(!lstrcmpA(path, "kiwi"),
10939        "Expected path to be unchanged, got \"%s\"\n", path);
10940     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10941
10942     /* source path does not exist, but the property exists */
10943     size = MAX_PATH;
10944     lstrcpyA(path, "kiwi");
10945     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10946     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10947     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10948     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10949
10950     /* try SubDir after ResolveSource */
10951     size = MAX_PATH;
10952     lstrcpyA(path, "kiwi");
10953     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
10954     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10955     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
10956     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
10957
10958     /* try SubDir2 after ResolveSource */
10959     size = MAX_PATH;
10960     lstrcpyA(path, "kiwi");
10961     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
10962     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10963     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
10964     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
10965
10966     r = MsiDoAction(hpkg, "FileCost");
10967     ok(r == ERROR_SUCCESS, "file cost failed\n");
10968
10969     /* try TARGETDIR after FileCost */
10970     size = MAX_PATH;
10971     lstrcpyA(path, "kiwi");
10972     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
10973     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10974     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10975     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10976
10977     /* try SourceDir after FileCost */
10978     size = MAX_PATH;
10979     lstrcpyA(path, "kiwi");
10980     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
10981     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10982     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
10983     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
10984
10985     /* try SOURCEDIR after FileCost */
10986     size = MAX_PATH;
10987     lstrcpyA(path, "kiwi");
10988     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
10989     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
10990     ok(!lstrcmpA(path, "kiwi"),
10991        "Expected path to be unchanged, got \"%s\"\n", path);
10992     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10993
10994     /* source path does not exist, but the property exists */
10995     size = MAX_PATH;
10996     lstrcpyA(path, "kiwi");
10997     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
10998     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10999     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11000     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11001
11002     /* try SubDir after FileCost */
11003     size = MAX_PATH;
11004     lstrcpyA(path, "kiwi");
11005     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11006     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11007     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11008     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11009
11010     /* try SubDir2 after FileCost */
11011     size = MAX_PATH;
11012     lstrcpyA(path, "kiwi");
11013     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11014     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11015     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11016     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11017
11018     r = MsiDoAction(hpkg, "CostFinalize");
11019     ok(r == ERROR_SUCCESS, "file cost failed\n");
11020
11021     /* try TARGETDIR after CostFinalize */
11022     size = MAX_PATH;
11023     lstrcpyA(path, "kiwi");
11024     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11025     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11026     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11027     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11028
11029     /* try SourceDir after CostFinalize */
11030     size = MAX_PATH;
11031     lstrcpyA(path, "kiwi");
11032     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11034     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11035     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11036
11037     /* try SOURCEDIR after CostFinalize */
11038     size = MAX_PATH;
11039     lstrcpyA(path, "kiwi");
11040     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11041     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11042     ok(!lstrcmpA(path, "kiwi"),
11043        "Expected path to be unchanged, got \"%s\"\n", path);
11044     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11045
11046     /* source path does not exist, but the property exists */
11047     size = MAX_PATH;
11048     lstrcpyA(path, "kiwi");
11049     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11050     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11051     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11052     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11053
11054     /* try SubDir after CostFinalize */
11055     size = MAX_PATH;
11056     lstrcpyA(path, "kiwi");
11057     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11058     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11059     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11060     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11061
11062     /* try SubDir2 after CostFinalize */
11063     size = MAX_PATH;
11064     lstrcpyA(path, "kiwi");
11065     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11066     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11067     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
11068     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
11069
11070     /* nonexistent directory */
11071     size = MAX_PATH;
11072     lstrcpyA(path, "kiwi");
11073     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
11074     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11075     ok(!lstrcmpA(path, "kiwi"),
11076        "Expected path to be unchanged, got \"%s\"\n", path);
11077     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11078
11079     /* NULL szPathBuf */
11080     size = MAX_PATH;
11081     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
11082     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11083     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11084
11085     /* NULL pcchPathBuf */
11086     lstrcpyA(path, "kiwi");
11087     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
11088     ok(r == ERROR_INVALID_PARAMETER,
11089        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11090     ok(!lstrcmpA(path, "kiwi"),
11091        "Expected path to be unchanged, got \"%s\"\n", path);
11092
11093     /* pcchPathBuf is 0 */
11094     size = 0;
11095     lstrcpyA(path, "kiwi");
11096     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11097     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11098     ok(!lstrcmpA(path, "kiwi"),
11099        "Expected path to be unchanged, got \"%s\"\n", path);
11100     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11101
11102     /* pcchPathBuf does not have room for NULL terminator */
11103     size = lstrlenA(cwd);
11104     lstrcpyA(path, "kiwi");
11105     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11106     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11107     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
11108        "Expected path with no backslash, got \"%s\"\n", path);
11109     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11110
11111     /* pcchPathBuf has room for NULL terminator */
11112     size = lstrlenA(cwd) + 1;
11113     lstrcpyA(path, "kiwi");
11114     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11115     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11116     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11117     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11118
11119     /* remove property */
11120     r = MsiSetProperty(hpkg, "SourceDir", NULL);
11121     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11122
11123     /* try SourceDir again */
11124     size = MAX_PATH;
11125     lstrcpyA(path, "kiwi");
11126     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11127     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11128     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11129     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11130
11131     /* set property to a valid directory */
11132     r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
11133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11134
11135     /* try SOURCEDIR again */
11136     size = MAX_PATH;
11137     lstrcpyA(path, "kiwi");
11138     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11139     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11140     ok(!lstrcmpA(path, "kiwi"),
11141        "Expected path to be unchanged, got \"%s\"\n", path);
11142     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11143
11144     MsiCloseHandle(hpkg);
11145
11146     /* compressed source */
11147
11148     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11149     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11150
11151     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
11152
11153     r = package_from_db(hdb, &hpkg);
11154     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11155
11156     /* try TARGETDIR */
11157     size = MAX_PATH;
11158     lstrcpyA(path, "kiwi");
11159     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11160     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11161     ok(!lstrcmpA(path, "kiwi"),
11162        "Expected path to be unchanged, got \"%s\"\n", path);
11163     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11164
11165     /* try SourceDir */
11166     size = MAX_PATH;
11167     lstrcpyA(path, "kiwi");
11168     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11169     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11170     ok(!lstrcmpA(path, "kiwi"),
11171        "Expected path to be unchanged, got \"%s\"\n", path);
11172     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11173
11174     /* try SOURCEDIR */
11175     size = MAX_PATH;
11176     lstrcpyA(path, "kiwi");
11177     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11178     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11179     ok(!lstrcmpA(path, "kiwi"),
11180        "Expected path to be unchanged, got \"%s\"\n", path);
11181     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11182
11183     /* source path nor the property exist */
11184     size = MAX_PATH;
11185     lstrcpyA(path, "kiwi");
11186     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11187     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11188     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11189     ok(size == 0, "Expected 0, got %d\n", size);
11190
11191     /* try SubDir */
11192     size = MAX_PATH;
11193     lstrcpyA(path, "kiwi");
11194     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11195     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11196     ok(!lstrcmpA(path, "kiwi"),
11197        "Expected path to be unchanged, got \"%s\"\n", path);
11198     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11199
11200     /* try SubDir2 */
11201     size = MAX_PATH;
11202     lstrcpyA(path, "kiwi");
11203     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11204     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11205     ok(!lstrcmpA(path, "kiwi"),
11206        "Expected path to be unchanged, got \"%s\"\n", path);
11207     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11208
11209     r = MsiDoAction(hpkg, "CostInitialize");
11210     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11211
11212     /* try TARGETDIR after CostInitialize */
11213     size = MAX_PATH;
11214     lstrcpyA(path, "kiwi");
11215     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11216     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11217     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11218     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11219
11220     /* try SourceDir after CostInitialize */
11221     size = MAX_PATH;
11222     lstrcpyA(path, "kiwi");
11223     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11224     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11225     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11226     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11227
11228     /* try SOURCEDIR after CostInitialize */
11229     size = MAX_PATH;
11230     lstrcpyA(path, "kiwi");
11231     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11232     todo_wine
11233     {
11234         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11235         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11236         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11237     }
11238
11239     /* source path does not exist, but the property exists */
11240     size = MAX_PATH;
11241     lstrcpyA(path, "kiwi");
11242     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11243     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11244     todo_wine
11245     {
11246         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11247         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11248     }
11249
11250     /* try SubDir after CostInitialize */
11251     size = MAX_PATH;
11252     lstrcpyA(path, "kiwi");
11253     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11254     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11255     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11256     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11257
11258     /* try SubDir2 after CostInitialize */
11259     size = MAX_PATH;
11260     lstrcpyA(path, "kiwi");
11261     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11262     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11263     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11264     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11265
11266     r = MsiDoAction(hpkg, "ResolveSource");
11267     ok(r == ERROR_SUCCESS, "file cost failed\n");
11268
11269     /* try TARGETDIR after ResolveSource */
11270     size = MAX_PATH;
11271     lstrcpyA(path, "kiwi");
11272     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11273     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11274     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11275     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11276
11277     /* try SourceDir after ResolveSource */
11278     size = MAX_PATH;
11279     lstrcpyA(path, "kiwi");
11280     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11281     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11282     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11283     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11284
11285     /* try SOURCEDIR after ResolveSource */
11286     size = MAX_PATH;
11287     lstrcpyA(path, "kiwi");
11288     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11289     todo_wine
11290     {
11291         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11292         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11293         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11294     }
11295
11296     /* source path and the property exist */
11297     size = MAX_PATH;
11298     lstrcpyA(path, "kiwi");
11299     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11301     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11302     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11303
11304     /* try SubDir after ResolveSource */
11305     size = MAX_PATH;
11306     lstrcpyA(path, "kiwi");
11307     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11308     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11309     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11310     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11311
11312     /* try SubDir2 after ResolveSource */
11313     size = MAX_PATH;
11314     lstrcpyA(path, "kiwi");
11315     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11316     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11317     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11318     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11319
11320     r = MsiDoAction(hpkg, "FileCost");
11321     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11322
11323     /* try TARGETDIR after CostFinalize */
11324     size = MAX_PATH;
11325     lstrcpyA(path, "kiwi");
11326     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11327     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11328     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11329     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11330
11331     /* try SourceDir after CostFinalize */
11332     size = MAX_PATH;
11333     lstrcpyA(path, "kiwi");
11334     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11335     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11336     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11337     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11338
11339     /* try SOURCEDIR after CostFinalize */
11340     size = MAX_PATH;
11341     lstrcpyA(path, "kiwi");
11342     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11343     todo_wine
11344     {
11345         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11346         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11347         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11348     }
11349
11350     /* source path and the property exist */
11351     size = MAX_PATH;
11352     lstrcpyA(path, "kiwi");
11353     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11354     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11355     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11356     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11357
11358     /* try SubDir after CostFinalize */
11359     size = MAX_PATH;
11360     lstrcpyA(path, "kiwi");
11361     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11362     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11363     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11364     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11365
11366     /* try SubDir2 after CostFinalize */
11367     size = MAX_PATH;
11368     lstrcpyA(path, "kiwi");
11369     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11370     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11371     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11372     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11373
11374     r = MsiDoAction(hpkg, "CostFinalize");
11375     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11376
11377     /* try TARGETDIR after CostFinalize */
11378     size = MAX_PATH;
11379     lstrcpyA(path, "kiwi");
11380     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
11381     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11382     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11383     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11384
11385     /* try SourceDir after CostFinalize */
11386     size = MAX_PATH;
11387     lstrcpyA(path, "kiwi");
11388     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11389     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11390     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11391     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11392
11393     /* try SOURCEDIR after CostFinalize */
11394     size = MAX_PATH;
11395     lstrcpyA(path, "kiwi");
11396     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11397     todo_wine
11398     {
11399         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11400         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11401         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11402     }
11403
11404     /* source path and the property exist */
11405     size = MAX_PATH;
11406     lstrcpyA(path, "kiwi");
11407     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11409     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11410     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11411
11412     /* try SubDir after CostFinalize */
11413     size = MAX_PATH;
11414     lstrcpyA(path, "kiwi");
11415     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11417     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11418     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11419
11420     /* try SubDir2 after CostFinalize */
11421     size = MAX_PATH;
11422     lstrcpyA(path, "kiwi");
11423     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11424     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11425     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11426     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11427
11428     MsiCloseHandle(hpkg);
11429     DeleteFile(msifile);
11430 }
11431
11432 static void test_shortlongsource(void)
11433 {
11434     MSIHANDLE hdb, hpkg;
11435     CHAR path[MAX_PATH];
11436     CHAR cwd[MAX_PATH];
11437     CHAR subsrc[MAX_PATH];
11438     DWORD size;
11439     UINT r;
11440
11441     lstrcpyA(cwd, CURR_DIR);
11442     lstrcatA(cwd, "\\");
11443
11444     lstrcpyA(subsrc, cwd);
11445     lstrcatA(subsrc, "long");
11446     lstrcatA(subsrc, "\\");
11447
11448     /* long file names */
11449
11450     hdb = create_package_db();
11451     ok( hdb, "failed to create database\n");
11452
11453     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
11454
11455     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11456     ok(r == S_OK, "failed\n");
11457
11458     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
11459     ok(r == S_OK, "failed\n");
11460
11461     /* CostInitialize:short */
11462     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
11463     ok(r == S_OK, "failed\n");
11464
11465     /* CostInitialize:long */
11466     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
11467     ok(r == S_OK, "failed\n");
11468
11469     /* FileCost:short */
11470     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
11471     ok(r == S_OK, "failed\n");
11472
11473     /* FileCost:long */
11474     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
11475     ok(r == S_OK, "failed\n");
11476
11477     /* CostFinalize:short */
11478     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
11479     ok(r == S_OK, "failed\n");
11480
11481     /* CostFinalize:long */
11482     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
11483     ok(r == S_OK, "failed\n");
11484
11485     MsiDatabaseCommit(hdb);
11486
11487     r = package_from_db(hdb, &hpkg);
11488     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11489     {
11490         skip("Not enough rights to perform tests\n");
11491         DeleteFile(msifile);
11492         return;
11493     }
11494     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11495
11496     MsiCloseHandle(hdb);
11497
11498     CreateDirectoryA("one", NULL);
11499     CreateDirectoryA("four", NULL);
11500
11501     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
11502
11503     r = MsiDoAction(hpkg, "CostInitialize");
11504     ok(r == ERROR_SUCCESS, "file cost failed\n");
11505
11506     CreateDirectory("five", NULL);
11507     CreateDirectory("eight", NULL);
11508
11509     r = MsiDoAction(hpkg, "FileCost");
11510     ok(r == ERROR_SUCCESS, "file cost failed\n");
11511
11512     CreateDirectory("nine", NULL);
11513     CreateDirectory("twelve", NULL);
11514
11515     r = MsiDoAction(hpkg, "CostFinalize");
11516     ok(r == ERROR_SUCCESS, "file cost failed\n");
11517
11518     /* neither short nor long source directories exist */
11519     size = MAX_PATH;
11520     lstrcpyA(path, "kiwi");
11521     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11522     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11523     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11524     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11525
11526     CreateDirectoryA("short", NULL);
11527
11528     /* short source directory exists */
11529     size = MAX_PATH;
11530     lstrcpyA(path, "kiwi");
11531     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11532     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11533     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11534     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11535
11536     CreateDirectoryA("long", NULL);
11537
11538     /* both short and long source directories exist */
11539     size = MAX_PATH;
11540     lstrcpyA(path, "kiwi");
11541     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11542     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11543     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11544     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11545
11546     lstrcpyA(subsrc, cwd);
11547     lstrcatA(subsrc, "two");
11548     lstrcatA(subsrc, "\\");
11549
11550     /* short dir exists before CostInitialize */
11551     size = MAX_PATH;
11552     lstrcpyA(path, "kiwi");
11553     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11555     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11556     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11557
11558     lstrcpyA(subsrc, cwd);
11559     lstrcatA(subsrc, "four");
11560     lstrcatA(subsrc, "\\");
11561
11562     /* long dir exists before CostInitialize */
11563     size = MAX_PATH;
11564     lstrcpyA(path, "kiwi");
11565     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11566     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11567     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11568     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11569
11570     lstrcpyA(subsrc, cwd);
11571     lstrcatA(subsrc, "six");
11572     lstrcatA(subsrc, "\\");
11573
11574     /* short dir exists before FileCost */
11575     size = MAX_PATH;
11576     lstrcpyA(path, "kiwi");
11577     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11579     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11580     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11581
11582     lstrcpyA(subsrc, cwd);
11583     lstrcatA(subsrc, "eight");
11584     lstrcatA(subsrc, "\\");
11585
11586     /* long dir exists before FileCost */
11587     size = MAX_PATH;
11588     lstrcpyA(path, "kiwi");
11589     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11590     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11591     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11592     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11593
11594     lstrcpyA(subsrc, cwd);
11595     lstrcatA(subsrc, "ten");
11596     lstrcatA(subsrc, "\\");
11597
11598     /* short dir exists before CostFinalize */
11599     size = MAX_PATH;
11600     lstrcpyA(path, "kiwi");
11601     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11603     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11604     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11605
11606     lstrcpyA(subsrc, cwd);
11607     lstrcatA(subsrc, "twelve");
11608     lstrcatA(subsrc, "\\");
11609
11610     /* long dir exists before CostFinalize */
11611     size = MAX_PATH;
11612     lstrcpyA(path, "kiwi");
11613     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11614     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11615     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11616     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11617
11618     MsiCloseHandle(hpkg);
11619     RemoveDirectoryA("short");
11620     RemoveDirectoryA("long");
11621     RemoveDirectoryA("one");
11622     RemoveDirectoryA("four");
11623     RemoveDirectoryA("five");
11624     RemoveDirectoryA("eight");
11625     RemoveDirectoryA("nine");
11626     RemoveDirectoryA("twelve");
11627
11628     /* short file names */
11629
11630     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
11631     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11632
11633     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
11634
11635     r = package_from_db(hdb, &hpkg);
11636     ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
11637
11638     MsiCloseHandle(hdb);
11639
11640     CreateDirectoryA("one", NULL);
11641     CreateDirectoryA("four", NULL);
11642
11643     r = MsiDoAction(hpkg, "CostInitialize");
11644     ok(r == ERROR_SUCCESS, "file cost failed\n");
11645
11646     CreateDirectory("five", NULL);
11647     CreateDirectory("eight", NULL);
11648
11649     r = MsiDoAction(hpkg, "FileCost");
11650     ok(r == ERROR_SUCCESS, "file cost failed\n");
11651
11652     CreateDirectory("nine", NULL);
11653     CreateDirectory("twelve", NULL);
11654
11655     r = MsiDoAction(hpkg, "CostFinalize");
11656     ok(r == ERROR_SUCCESS, "file cost failed\n");
11657
11658     lstrcpyA(subsrc, cwd);
11659     lstrcatA(subsrc, "short");
11660     lstrcatA(subsrc, "\\");
11661
11662     /* neither short nor long source directories exist */
11663     size = MAX_PATH;
11664     lstrcpyA(path, "kiwi");
11665     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11666     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11667     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11668     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11669
11670     CreateDirectoryA("short", NULL);
11671
11672     /* short source directory exists */
11673     size = MAX_PATH;
11674     lstrcpyA(path, "kiwi");
11675     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11676     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11677     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11678     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11679
11680     CreateDirectoryA("long", NULL);
11681
11682     /* both short and long source directories exist */
11683     size = MAX_PATH;
11684     lstrcpyA(path, "kiwi");
11685     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
11686     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11687     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11688     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11689
11690     lstrcpyA(subsrc, cwd);
11691     lstrcatA(subsrc, "one");
11692     lstrcatA(subsrc, "\\");
11693
11694     /* short dir exists before CostInitialize */
11695     size = MAX_PATH;
11696     lstrcpyA(path, "kiwi");
11697     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
11698     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11699     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11700     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11701
11702     lstrcpyA(subsrc, cwd);
11703     lstrcatA(subsrc, "three");
11704     lstrcatA(subsrc, "\\");
11705
11706     /* long dir exists before CostInitialize */
11707     size = MAX_PATH;
11708     lstrcpyA(path, "kiwi");
11709     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
11710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11711     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11712     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11713
11714     lstrcpyA(subsrc, cwd);
11715     lstrcatA(subsrc, "five");
11716     lstrcatA(subsrc, "\\");
11717
11718     /* short dir exists before FileCost */
11719     size = MAX_PATH;
11720     lstrcpyA(path, "kiwi");
11721     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
11722     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11723     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11724     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11725
11726     lstrcpyA(subsrc, cwd);
11727     lstrcatA(subsrc, "seven");
11728     lstrcatA(subsrc, "\\");
11729
11730     /* long dir exists before FileCost */
11731     size = MAX_PATH;
11732     lstrcpyA(path, "kiwi");
11733     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
11734     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11735     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11736     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11737
11738     lstrcpyA(subsrc, cwd);
11739     lstrcatA(subsrc, "nine");
11740     lstrcatA(subsrc, "\\");
11741
11742     /* short dir exists before CostFinalize */
11743     size = MAX_PATH;
11744     lstrcpyA(path, "kiwi");
11745     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
11746     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11747     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11748     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11749
11750     lstrcpyA(subsrc, cwd);
11751     lstrcatA(subsrc, "eleven");
11752     lstrcatA(subsrc, "\\");
11753
11754     /* long dir exists before CostFinalize */
11755     size = MAX_PATH;
11756     lstrcpyA(path, "kiwi");
11757     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
11758     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11759     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
11760     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
11761
11762     MsiCloseHandle(hpkg);
11763     RemoveDirectoryA("short");
11764     RemoveDirectoryA("long");
11765     RemoveDirectoryA("one");
11766     RemoveDirectoryA("four");
11767     RemoveDirectoryA("five");
11768     RemoveDirectoryA("eight");
11769     RemoveDirectoryA("nine");
11770     RemoveDirectoryA("twelve");
11771     DeleteFileA(msifile);
11772 }
11773
11774 static void test_sourcedir(void)
11775 {
11776     MSIHANDLE hdb, hpkg;
11777     CHAR package[12];
11778     CHAR path[MAX_PATH];
11779     CHAR cwd[MAX_PATH];
11780     CHAR subsrc[MAX_PATH];
11781     DWORD size;
11782     UINT r;
11783
11784     lstrcpyA(cwd, CURR_DIR);
11785     lstrcatA(cwd, "\\");
11786
11787     lstrcpyA(subsrc, cwd);
11788     lstrcatA(subsrc, "long");
11789     lstrcatA(subsrc, "\\");
11790
11791     hdb = create_package_db();
11792     ok( hdb, "failed to create database\n");
11793
11794     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
11795     ok(r == S_OK, "failed\n");
11796
11797     sprintf(package, "#%u", hdb);
11798     r = MsiOpenPackage(package, &hpkg);
11799     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
11800     {
11801         skip("Not enough rights to perform tests\n");
11802         goto error;
11803     }
11804     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11805
11806     /* properties only */
11807
11808     /* SourceDir prop */
11809     size = MAX_PATH;
11810     lstrcpyA(path, "kiwi");
11811     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11812     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11813     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11814     ok(size == 0, "Expected 0, got %d\n", size);
11815
11816     /* SOURCEDIR prop */
11817     size = MAX_PATH;
11818     lstrcpyA(path, "kiwi");
11819     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11820     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11821     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11822     ok(size == 0, "Expected 0, got %d\n", size);
11823
11824     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
11825
11826     r = MsiDoAction(hpkg, "CostInitialize");
11827     ok(r == ERROR_SUCCESS, "file cost failed\n");
11828
11829     /* SourceDir after CostInitialize */
11830     size = MAX_PATH;
11831     lstrcpyA(path, "kiwi");
11832     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11833     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11834     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11835     ok(size == 0, "Expected 0, got %d\n", size);
11836
11837     /* SOURCEDIR after CostInitialize */
11838     size = MAX_PATH;
11839     lstrcpyA(path, "kiwi");
11840     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11841     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11842     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11843     ok(size == 0, "Expected 0, got %d\n", size);
11844
11845     r = MsiDoAction(hpkg, "FileCost");
11846     ok(r == ERROR_SUCCESS, "file cost failed\n");
11847
11848     /* SourceDir after FileCost */
11849     size = MAX_PATH;
11850     lstrcpyA(path, "kiwi");
11851     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11853     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11854     ok(size == 0, "Expected 0, got %d\n", size);
11855
11856     /* SOURCEDIR after FileCost */
11857     size = MAX_PATH;
11858     lstrcpyA(path, "kiwi");
11859     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11860     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11861     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11862     ok(size == 0, "Expected 0, got %d\n", size);
11863
11864     r = MsiDoAction(hpkg, "CostFinalize");
11865     ok(r == ERROR_SUCCESS, "file cost failed\n");
11866
11867     /* SourceDir after CostFinalize */
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 after CostFinalize */
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     r = MsiDoAction(hpkg, "ResolveSource");
11884     ok(r == ERROR_SUCCESS, "file cost failed\n");
11885
11886     /* SourceDir after ResolveSource */
11887     size = MAX_PATH;
11888     lstrcpyA(path, "kiwi");
11889     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11890     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11891     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11892     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11893
11894     /* SOURCEDIR after ResolveSource */
11895     size = MAX_PATH;
11896     lstrcpyA(path, "kiwi");
11897     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11898     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11899     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11900     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11901
11902     /* random casing */
11903     size = MAX_PATH;
11904     lstrcpyA(path, "kiwi");
11905     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
11906     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11907     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11908     ok(size == 0, "Expected 0, got %d\n", size);
11909
11910     MsiCloseHandle(hpkg);
11911
11912     /* reset the package state */
11913     sprintf(package, "#%i", hdb);
11914     r = MsiOpenPackage(package, &hpkg);
11915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11916
11917     /* test how MsiGetSourcePath affects the properties */
11918
11919     /* SourceDir prop */
11920     size = MAX_PATH;
11921     lstrcpyA(path, "kiwi");
11922     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11923     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11924     todo_wine
11925     {
11926         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11927         ok(size == 0, "Expected 0, got %d\n", size);
11928     }
11929
11930     size = MAX_PATH;
11931     lstrcpyA(path, "kiwi");
11932     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11933     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11934     ok(!lstrcmpA(path, "kiwi"),
11935        "Expected path to be unchanged, got \"%s\"\n", path);
11936     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11937
11938     /* SourceDir after MsiGetSourcePath */
11939     size = MAX_PATH;
11940     lstrcpyA(path, "kiwi");
11941     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11942     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11943     todo_wine
11944     {
11945         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11946         ok(size == 0, "Expected 0, got %d\n", size);
11947     }
11948
11949     /* SOURCEDIR prop */
11950     size = MAX_PATH;
11951     lstrcpyA(path, "kiwi");
11952     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11953     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11954     todo_wine
11955     {
11956         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11957         ok(size == 0, "Expected 0, got %d\n", size);
11958     }
11959
11960     size = MAX_PATH;
11961     lstrcpyA(path, "kiwi");
11962     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
11963     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
11964     ok(!lstrcmpA(path, "kiwi"),
11965        "Expected path to be unchanged, got \"%s\"\n", path);
11966     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11967
11968     /* SOURCEDIR prop after MsiGetSourcePath */
11969     size = MAX_PATH;
11970     lstrcpyA(path, "kiwi");
11971     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
11972     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11973     todo_wine
11974     {
11975         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11976         ok(size == 0, "Expected 0, got %d\n", size);
11977     }
11978
11979     r = MsiDoAction(hpkg, "CostInitialize");
11980     ok(r == ERROR_SUCCESS, "file cost failed\n");
11981
11982     /* SourceDir after CostInitialize */
11983     size = MAX_PATH;
11984     lstrcpyA(path, "kiwi");
11985     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
11986     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11987     todo_wine
11988     {
11989         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
11990         ok(size == 0, "Expected 0, got %d\n", size);
11991     }
11992
11993     size = MAX_PATH;
11994     lstrcpyA(path, "kiwi");
11995     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
11996     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11997     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
11998     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
11999
12000     /* SourceDir after MsiGetSourcePath */
12001     size = MAX_PATH;
12002     lstrcpyA(path, "kiwi");
12003     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12004     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12005     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12006     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12007
12008     /* SOURCEDIR after CostInitialize */
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     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12014     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12015
12016     /* SOURCEDIR source path still does not exist */
12017     size = MAX_PATH;
12018     lstrcpyA(path, "kiwi");
12019     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12020     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12021     ok(!lstrcmpA(path, "kiwi"),
12022        "Expected path to be unchanged, got \"%s\"\n", path);
12023     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12024
12025     r = MsiDoAction(hpkg, "FileCost");
12026     ok(r == ERROR_SUCCESS, "file cost failed\n");
12027
12028     /* SourceDir after FileCost */
12029     size = MAX_PATH;
12030     lstrcpyA(path, "kiwi");
12031     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12032     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12033     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12034     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12035
12036     /* SOURCEDIR after FileCost */
12037     size = MAX_PATH;
12038     lstrcpyA(path, "kiwi");
12039     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12040     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12041     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12042     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12043
12044     /* SOURCEDIR source path still does not exist */
12045     size = MAX_PATH;
12046     lstrcpyA(path, "kiwi");
12047     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12048     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12049     ok(!lstrcmpA(path, "kiwi"),
12050        "Expected path to be unchanged, got \"%s\"\n", path);
12051     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12052
12053     r = MsiDoAction(hpkg, "CostFinalize");
12054     ok(r == ERROR_SUCCESS, "file cost failed\n");
12055
12056     /* SourceDir after CostFinalize */
12057     size = MAX_PATH;
12058     lstrcpyA(path, "kiwi");
12059     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12060     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12061     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12062     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12063
12064     /* SOURCEDIR after CostFinalize */
12065     size = MAX_PATH;
12066     lstrcpyA(path, "kiwi");
12067     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12068     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12069     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12070     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12071
12072     /* SOURCEDIR source path still does not exist */
12073     size = MAX_PATH;
12074     lstrcpyA(path, "kiwi");
12075     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12076     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12077     ok(!lstrcmpA(path, "kiwi"),
12078        "Expected path to be unchanged, got \"%s\"\n", path);
12079     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12080
12081     r = MsiDoAction(hpkg, "ResolveSource");
12082     ok(r == ERROR_SUCCESS, "file cost failed\n");
12083
12084     /* SourceDir after ResolveSource */
12085     size = MAX_PATH;
12086     lstrcpyA(path, "kiwi");
12087     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
12088     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12089     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12090     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12091
12092     /* SOURCEDIR after ResolveSource */
12093     size = MAX_PATH;
12094     lstrcpyA(path, "kiwi");
12095     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
12096     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12097     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
12098     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
12099
12100     /* SOURCEDIR source path still does not exist */
12101     size = MAX_PATH;
12102     lstrcpyA(path, "kiwi");
12103     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
12104     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
12105     ok(!lstrcmpA(path, "kiwi"),
12106        "Expected path to be unchanged, got \"%s\"\n", path);
12107     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12108
12109     MsiCloseHandle(hpkg);
12110
12111 error:
12112     MsiCloseHandle(hdb);
12113     DeleteFileA(msifile);
12114 }
12115
12116 struct access_res
12117 {
12118     BOOL gothandle;
12119     DWORD lasterr;
12120     BOOL ignore;
12121 };
12122
12123 static const struct access_res create[16] =
12124 {
12125     { TRUE, ERROR_SUCCESS, TRUE },
12126     { TRUE, ERROR_SUCCESS, TRUE },
12127     { TRUE, ERROR_SUCCESS, FALSE },
12128     { TRUE, ERROR_SUCCESS, FALSE },
12129     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12130     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12131     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12132     { TRUE, ERROR_SUCCESS, FALSE },
12133     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12134     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12135     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12136     { TRUE, ERROR_SUCCESS, TRUE },
12137     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12138     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12139     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12140     { TRUE, ERROR_SUCCESS, TRUE }
12141 };
12142
12143 static const struct access_res create_commit[16] =
12144 {
12145     { TRUE, ERROR_SUCCESS, TRUE },
12146     { TRUE, ERROR_SUCCESS, TRUE },
12147     { TRUE, ERROR_SUCCESS, FALSE },
12148     { TRUE, ERROR_SUCCESS, FALSE },
12149     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12150     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12151     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12152     { TRUE, ERROR_SUCCESS, FALSE },
12153     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12154     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12155     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12156     { TRUE, ERROR_SUCCESS, TRUE },
12157     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12158     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12159     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
12160     { TRUE, ERROR_SUCCESS, TRUE }
12161 };
12162
12163 static const struct access_res create_close[16] =
12164 {
12165     { TRUE, ERROR_SUCCESS, FALSE },
12166     { TRUE, ERROR_SUCCESS, FALSE },
12167     { TRUE, ERROR_SUCCESS, FALSE },
12168     { TRUE, ERROR_SUCCESS, FALSE },
12169     { TRUE, ERROR_SUCCESS, FALSE },
12170     { TRUE, ERROR_SUCCESS, FALSE },
12171     { TRUE, ERROR_SUCCESS, FALSE },
12172     { TRUE, ERROR_SUCCESS, FALSE },
12173     { TRUE, ERROR_SUCCESS, FALSE },
12174     { TRUE, ERROR_SUCCESS, FALSE },
12175     { TRUE, ERROR_SUCCESS, FALSE },
12176     { TRUE, ERROR_SUCCESS, FALSE },
12177     { TRUE, ERROR_SUCCESS, FALSE },
12178     { TRUE, ERROR_SUCCESS, FALSE },
12179     { TRUE, ERROR_SUCCESS, FALSE },
12180     { TRUE, ERROR_SUCCESS }
12181 };
12182
12183 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
12184 {
12185     DWORD access = 0, share = 0;
12186     DWORD lasterr;
12187     HANDLE hfile;
12188     int i, j, idx = 0;
12189
12190     for (i = 0; i < 4; i++)
12191     {
12192         if (i == 0) access = 0;
12193         if (i == 1) access = GENERIC_READ;
12194         if (i == 2) access = GENERIC_WRITE;
12195         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
12196
12197         for (j = 0; j < 4; j++)
12198         {
12199             if (ares[idx].ignore)
12200                 continue;
12201
12202             if (j == 0) share = 0;
12203             if (j == 1) share = FILE_SHARE_READ;
12204             if (j == 2) share = FILE_SHARE_WRITE;
12205             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
12206
12207             SetLastError(0xdeadbeef);
12208             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
12209                                 FILE_ATTRIBUTE_NORMAL, 0);
12210             lasterr = GetLastError();
12211
12212             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
12213                "(%d, handle, %d): Expected %d, got %d\n",
12214                line, idx, ares[idx].gothandle,
12215                (hfile != INVALID_HANDLE_VALUE));
12216
12217             ok(lasterr == ares[idx].lasterr ||
12218                lasterr == 0xdeadbeef, /* win9x */
12219                "(%d, lasterr, %d): Expected %d, got %d\n",
12220                line, idx, ares[idx].lasterr, lasterr);
12221
12222             CloseHandle(hfile);
12223             idx++;
12224         }
12225     }
12226 }
12227
12228 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
12229
12230 static void test_access(void)
12231 {
12232     MSIHANDLE hdb;
12233     UINT r;
12234
12235     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
12236     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12237
12238     test_file_access(msifile, create);
12239
12240     r = MsiDatabaseCommit(hdb);
12241     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12242
12243     test_file_access(msifile, create_commit);
12244     MsiCloseHandle(hdb);
12245
12246     test_file_access(msifile, create_close);
12247     DeleteFileA(msifile);
12248
12249     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
12250     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12251
12252     test_file_access(msifile, create);
12253
12254     r = MsiDatabaseCommit(hdb);
12255     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12256
12257     test_file_access(msifile, create_commit);
12258     MsiCloseHandle(hdb);
12259
12260     test_file_access(msifile, create_close);
12261     DeleteFileA(msifile);
12262 }
12263
12264 static void test_emptypackage(void)
12265 {
12266     MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
12267     MSIHANDLE hview = 0, hrec = 0;
12268     MSICONDITION condition;
12269     CHAR buffer[MAX_PATH];
12270     DWORD size;
12271     UINT r;
12272
12273     r = MsiOpenPackageA("", &hpkg);
12274     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12275     {
12276         skip("Not enough rights to perform tests\n");
12277         return;
12278     }
12279     todo_wine
12280     {
12281         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12282     }
12283
12284     hdb = MsiGetActiveDatabase(hpkg);
12285     todo_wine
12286     {
12287         ok(hdb != 0, "Expected a valid database handle\n");
12288     }
12289
12290     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
12291     todo_wine
12292     {
12293         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12294     }
12295     r = MsiViewExecute(hview, 0);
12296     todo_wine
12297     {
12298         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12299     }
12300
12301     r = MsiViewFetch(hview, &hrec);
12302     todo_wine
12303     {
12304         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12305     }
12306
12307     buffer[0] = 0;
12308     size = MAX_PATH;
12309     r = MsiRecordGetString(hrec, 1, buffer, &size);
12310     todo_wine
12311     {
12312         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12313         ok(!lstrcmpA(buffer, "_Property"),
12314            "Expected \"_Property\", got \"%s\"\n", buffer);
12315     }
12316
12317     MsiCloseHandle(hrec);
12318
12319     r = MsiViewFetch(hview, &hrec);
12320     todo_wine
12321     {
12322         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12323     }
12324
12325     size = MAX_PATH;
12326     r = MsiRecordGetString(hrec, 1, buffer, &size);
12327     todo_wine
12328     {
12329         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12330         ok(!lstrcmpA(buffer, "#_FolderCache"),
12331            "Expected \"_Property\", got \"%s\"\n", buffer);
12332     }
12333
12334     MsiCloseHandle(hrec);
12335     MsiViewClose(hview);
12336     MsiCloseHandle(hview);
12337
12338     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
12339     todo_wine
12340     {
12341         ok(condition == MSICONDITION_FALSE,
12342            "Expected MSICONDITION_FALSE, got %d\n", condition);
12343     }
12344
12345     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
12346     todo_wine
12347     {
12348         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12349     }
12350     r = MsiViewExecute(hview, 0);
12351     todo_wine
12352     {
12353         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12354     }
12355
12356     /* _Property table is not empty */
12357     r = MsiViewFetch(hview, &hrec);
12358     todo_wine
12359     {
12360         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12361     }
12362
12363     MsiCloseHandle(hrec);
12364     MsiViewClose(hview);
12365     MsiCloseHandle(hview);
12366
12367     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
12368     todo_wine
12369     {
12370         ok(condition == MSICONDITION_FALSE,
12371            "Expected MSICONDITION_FALSE, got %d\n", condition);
12372     }
12373
12374     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
12375     todo_wine
12376     {
12377         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12378     }
12379     r = MsiViewExecute(hview, 0);
12380     todo_wine
12381     {
12382         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12383     }
12384
12385     /* #_FolderCache is not empty */
12386     r = MsiViewFetch(hview, &hrec);
12387     todo_wine
12388     {
12389         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12390     }
12391
12392     MsiCloseHandle(hrec);
12393     MsiViewClose(hview);
12394     MsiCloseHandle(hview);
12395
12396     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
12397     todo_wine
12398     {
12399         ok(r == ERROR_BAD_QUERY_SYNTAX,
12400            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12401     }
12402
12403     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
12404     todo_wine
12405     {
12406         ok(r == ERROR_BAD_QUERY_SYNTAX,
12407            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12408     }
12409
12410     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
12411     todo_wine
12412     {
12413         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
12414            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
12415     }
12416
12417     MsiCloseHandle(hsuminfo);
12418
12419     r = MsiDatabaseCommit(hdb);
12420     todo_wine
12421     {
12422         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12423     }
12424
12425     MsiCloseHandle(hdb);
12426     MsiCloseHandle(hpkg);
12427 }
12428
12429 static void test_MsiGetProductProperty(void)
12430 {
12431     MSIHANDLE hprod, hdb;
12432     CHAR val[MAX_PATH];
12433     CHAR path[MAX_PATH];
12434     CHAR query[MAX_PATH];
12435     CHAR keypath[MAX_PATH*2];
12436     CHAR prodcode[MAX_PATH];
12437     CHAR prod_squashed[MAX_PATH];
12438     HKEY prodkey, userkey, props;
12439     DWORD size;
12440     LONG res;
12441     UINT r;
12442     SC_HANDLE scm;
12443     REGSAM access = KEY_ALL_ACCESS;
12444
12445     scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
12446     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
12447     {
12448         win_skip("Different registry keys on Win9x and WinMe\n");
12449         return;
12450     }
12451     CloseServiceHandle(scm);
12452
12453     GetCurrentDirectoryA(MAX_PATH, path);
12454     lstrcatA(path, "\\");
12455
12456     create_test_guid(prodcode, prod_squashed);
12457
12458     if (is_wow64)
12459         access |= KEY_WOW64_64KEY;
12460
12461     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
12462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12463
12464     r = MsiDatabaseCommit(hdb);
12465     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12466
12467     r = set_summary_info(hdb);
12468     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12469
12470     r = run_query(hdb,
12471             "CREATE TABLE `Directory` ( "
12472             "`Directory` CHAR(255) NOT NULL, "
12473             "`Directory_Parent` CHAR(255), "
12474             "`DefaultDir` CHAR(255) NOT NULL "
12475             "PRIMARY KEY `Directory`)");
12476     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12477
12478     r = run_query(hdb,
12479             "CREATE TABLE `Property` ( "
12480             "`Property` CHAR(72) NOT NULL, "
12481             "`Value` CHAR(255) "
12482             "PRIMARY KEY `Property`)");
12483     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12484
12485     sprintf(query, "INSERT INTO `Property` "
12486             "(`Property`, `Value`) "
12487             "VALUES( 'ProductCode', '%s' )", prodcode);
12488     r = run_query(hdb, query);
12489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12490
12491     r = MsiDatabaseCommit(hdb);
12492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12493
12494     MsiCloseHandle(hdb);
12495
12496     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12497     lstrcatA(keypath, prod_squashed);
12498
12499     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12500     if (res == ERROR_ACCESS_DENIED)
12501     {
12502         skip("Not enough rights to perform tests\n");
12503         DeleteFile(msifile);
12504         return;
12505     }
12506     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12507
12508     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
12509     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
12510     lstrcatA(keypath, prod_squashed);
12511
12512     res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
12513     if (res == ERROR_ACCESS_DENIED)
12514     {
12515         skip("Not enough rights to perform tests\n");
12516         RegDeleteKeyA(prodkey, "");
12517         RegCloseKey(prodkey);
12518         return;
12519     }
12520     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12521
12522     res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12523     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12524
12525     lstrcpyA(val, path);
12526     lstrcatA(val, "\\");
12527     lstrcatA(val, msifile);
12528     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
12529                          (const BYTE *)val, lstrlenA(val) + 1);
12530     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12531
12532     hprod = 0xdeadbeef;
12533     r = MsiOpenProductA(prodcode, &hprod);
12534     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12535     ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
12536
12537     /* hProduct is invalid */
12538     size = MAX_PATH;
12539     lstrcpyA(val, "apple");
12540     r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
12541     ok(r == ERROR_INVALID_HANDLE,
12542        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12543     ok(!lstrcmpA(val, "apple"),
12544        "Expected val to be unchanged, got \"%s\"\n", val);
12545     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12546
12547     /* szProperty is NULL */
12548     size = MAX_PATH;
12549     lstrcpyA(val, "apple");
12550     r = MsiGetProductPropertyA(hprod, NULL, val, &size);
12551     ok(r == ERROR_INVALID_PARAMETER,
12552        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12553     ok(!lstrcmpA(val, "apple"),
12554        "Expected val to be unchanged, got \"%s\"\n", val);
12555     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12556
12557     /* szProperty is empty */
12558     size = MAX_PATH;
12559     lstrcpyA(val, "apple");
12560     r = MsiGetProductPropertyA(hprod, "", val, &size);
12561     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12562     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12563     ok(size == 0, "Expected 0, got %d\n", size);
12564
12565     /* get the property */
12566     size = MAX_PATH;
12567     lstrcpyA(val, "apple");
12568     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12569     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12570     ok(!lstrcmpA(val, prodcode),
12571        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12572     ok(size == lstrlenA(prodcode),
12573        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12574
12575     /* lpValueBuf is NULL */
12576     size = MAX_PATH;
12577     r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
12578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12579     ok(size == lstrlenA(prodcode),
12580        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12581
12582     /* pcchValueBuf is NULL */
12583     lstrcpyA(val, "apple");
12584     r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
12585     ok(r == ERROR_INVALID_PARAMETER,
12586        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12587     ok(!lstrcmpA(val, "apple"),
12588        "Expected val to be unchanged, got \"%s\"\n", val);
12589     ok(size == lstrlenA(prodcode),
12590        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12591
12592     /* pcchValueBuf is too small */
12593     size = 4;
12594     lstrcpyA(val, "apple");
12595     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12596     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12597     ok(!strncmp(val, prodcode, 3),
12598        "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
12599     ok(size == lstrlenA(prodcode),
12600        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12601
12602     /* pcchValueBuf does not leave room for NULL terminator */
12603     size = lstrlenA(prodcode);
12604     lstrcpyA(val, "apple");
12605     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12606     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12607     ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
12608        "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
12609     ok(size == lstrlenA(prodcode),
12610        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12611
12612     /* pcchValueBuf has enough room for NULL terminator */
12613     size = lstrlenA(prodcode) + 1;
12614     lstrcpyA(val, "apple");
12615     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12616     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12617     ok(!lstrcmpA(val, prodcode),
12618        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12619     ok(size == lstrlenA(prodcode),
12620        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12621
12622     /* nonexistent property */
12623     size = MAX_PATH;
12624     lstrcpyA(val, "apple");
12625     r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
12626     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12627     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12628     ok(size == 0, "Expected 0, got %d\n", size);
12629
12630     r = MsiSetPropertyA(hprod, "NewProperty", "value");
12631     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12632
12633     /* non-product property set */
12634     size = MAX_PATH;
12635     lstrcpyA(val, "apple");
12636     r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
12637     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12638     ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12639     ok(size == 0, "Expected 0, got %d\n", size);
12640
12641     r = MsiSetPropertyA(hprod, "ProductCode", "value");
12642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12643
12644     /* non-product property that is also a product property set */
12645     size = MAX_PATH;
12646     lstrcpyA(val, "apple");
12647     r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
12648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12649     ok(!lstrcmpA(val, prodcode),
12650        "Expected \"%s\", got \"%s\"\n", prodcode, val);
12651     ok(size == lstrlenA(prodcode),
12652        "Expected %d, got %d\n", lstrlenA(prodcode), size);
12653
12654     MsiCloseHandle(hprod);
12655
12656     RegDeleteValueA(props, "LocalPackage");
12657     delete_key(props, "", access);
12658     RegCloseKey(props);
12659     delete_key(userkey, "", access);
12660     RegCloseKey(userkey);
12661     delete_key(prodkey, "", access);
12662     RegCloseKey(prodkey);
12663     DeleteFileA(msifile);
12664 }
12665
12666 static void test_MsiSetProperty(void)
12667 {
12668     MSIHANDLE hpkg, hdb, hrec;
12669     CHAR buf[MAX_PATH];
12670     LPCSTR query;
12671     DWORD size;
12672     UINT r;
12673
12674     r = package_from_db(create_package_db(), &hpkg);
12675     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
12676     {
12677         skip("Not enough rights to perform tests\n");
12678         DeleteFile(msifile);
12679         return;
12680     }
12681     ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
12682
12683     /* invalid hInstall */
12684     r = MsiSetPropertyA(0, "Prop", "Val");
12685     ok(r == ERROR_INVALID_HANDLE,
12686        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12687
12688     /* invalid hInstall */
12689     r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
12690     ok(r == ERROR_INVALID_HANDLE,
12691        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
12692
12693     /* szName is NULL */
12694     r = MsiSetPropertyA(hpkg, NULL, "Val");
12695     ok(r == ERROR_INVALID_PARAMETER,
12696        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12697
12698     /* both szName and szValue are NULL */
12699     r = MsiSetPropertyA(hpkg, NULL, NULL);
12700     ok(r == ERROR_INVALID_PARAMETER,
12701        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12702
12703     /* szName is empty */
12704     r = MsiSetPropertyA(hpkg, "", "Val");
12705     ok(r == ERROR_FUNCTION_FAILED,
12706        "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
12707
12708     /* szName is empty and szValue is NULL */
12709     r = MsiSetPropertyA(hpkg, "", NULL);
12710     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12711
12712     /* set a property */
12713     r = MsiSetPropertyA(hpkg, "Prop", "Val");
12714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12715
12716     /* get the property */
12717     size = MAX_PATH;
12718     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12720     ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
12721     ok(size == 3, "Expected 3, got %d\n", size);
12722
12723     /* update the property */
12724     r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
12725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12726
12727     /* get the property */
12728     size = MAX_PATH;
12729     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12731     ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
12732     ok(size == 4, "Expected 4, got %d\n", size);
12733
12734     hdb = MsiGetActiveDatabase(hpkg);
12735     ok(hdb != 0, "Expected a valid database handle\n");
12736
12737     /* set prop is not in the _Property table */
12738     query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
12739     r = do_query(hdb, query, &hrec);
12740     ok(r == ERROR_BAD_QUERY_SYNTAX,
12741        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12742
12743     /* set prop is not in the Property table */
12744     query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
12745     r = do_query(hdb, query, &hrec);
12746     ok(r == ERROR_BAD_QUERY_SYNTAX,
12747        "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
12748
12749     MsiCloseHandle(hdb);
12750
12751     /* szValue is an empty string */
12752     r = MsiSetPropertyA(hpkg, "Prop", "");
12753     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12754
12755     /* try to get the property */
12756     size = MAX_PATH;
12757     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12758     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12759     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12760     ok(size == 0, "Expected 0, got %d\n", size);
12761
12762     /* reset the property */
12763     r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
12764     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12765
12766     /* delete the property */
12767     r = MsiSetPropertyA(hpkg, "Prop", NULL);
12768     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12769
12770     /* try to get the property */
12771     size = MAX_PATH;
12772     r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
12773     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12774     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
12775     ok(size == 0, "Expected 0, got %d\n", size);
12776
12777     MsiCloseHandle(hpkg);
12778     DeleteFileA(msifile);
12779 }
12780
12781 static void test_MsiApplyMultiplePatches(void)
12782 {
12783     UINT r, type = GetDriveType(NULL);
12784
12785     if (!pMsiApplyMultiplePatchesA) {
12786         win_skip("MsiApplyMultiplePatchesA not found\n");
12787         return;
12788     }
12789
12790     r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
12791     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12792
12793     r = pMsiApplyMultiplePatchesA("", NULL, NULL);
12794     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12795
12796     r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
12797     if (type == DRIVE_FIXED)
12798         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12799     else
12800         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12801
12802     r = pMsiApplyMultiplePatchesA("  ;", NULL, NULL);
12803     if (type == DRIVE_FIXED)
12804         todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
12805     else
12806         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12807
12808     r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
12809     if (type == DRIVE_FIXED)
12810         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12811     else
12812         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12813
12814     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
12815     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12816
12817     r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
12818     if (type == DRIVE_FIXED)
12819         todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
12820     else
12821         ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
12822
12823     r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
12824     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12825
12826     r = pMsiApplyMultiplePatchesA("  nosuchpatchpackage  ;  nosuchpatchpackage  ", NULL, NULL);
12827     todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
12828 }
12829
12830 static void test_MsiApplyPatch(void)
12831 {
12832     UINT r;
12833
12834     r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
12835     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12836
12837     r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
12838     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12839 }
12840
12841 START_TEST(package)
12842 {
12843     STATEMGRSTATUS status;
12844     BOOL ret = FALSE;
12845
12846     init_functionpointers();
12847
12848     if (pIsWow64Process)
12849         pIsWow64Process(GetCurrentProcess(), &is_wow64);
12850
12851     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
12852
12853     /* Create a restore point ourselves so we circumvent the multitude of restore points
12854      * that would have been created by all the installation and removal tests.
12855      *
12856      * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
12857      * creation of restore points.
12858      */
12859     if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
12860     {
12861         memset(&status, 0, sizeof(status));
12862         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
12863     }
12864
12865     test_createpackage();
12866     test_doaction();
12867     test_gettargetpath_bad();
12868     test_settargetpath();
12869     test_props();
12870     test_property_table();
12871     test_condition();
12872     test_msipackage();
12873     test_formatrecord2();
12874     test_states();
12875     test_getproperty();
12876     test_removefiles();
12877     test_appsearch();
12878     test_appsearch_complocator();
12879     test_appsearch_reglocator();
12880     test_appsearch_inilocator();
12881     test_appsearch_drlocator();
12882     test_featureparents();
12883     test_installprops();
12884     test_launchconditions();
12885     test_ccpsearch();
12886     test_complocator();
12887     test_MsiGetSourcePath();
12888     test_shortlongsource();
12889     test_sourcedir();
12890     test_access();
12891     test_emptypackage();
12892     test_MsiGetProductProperty();
12893     test_MsiSetProperty();
12894     test_MsiApplyMultiplePatches();
12895     test_MsiApplyPatch();
12896
12897     if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
12898     {
12899         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
12900         if (ret)
12901             remove_restore_point(status.llSequenceNumber);
12902     }
12903 }