msi: Check the file version when a version is provided in the signature.
[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
30 #include "wine/test.h"
31
32 static const char msifile[] = "winetest.msi";
33 char CURR_DIR[MAX_PATH];
34
35 static void get_user_sid(LPSTR *usersid)
36 {
37     HANDLE token;
38     BYTE buf[1024];
39     DWORD size;
40     PTOKEN_USER user;
41     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
42     static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
43
44     *usersid = NULL;
45     pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
46     if (!pConvertSidToStringSidA)
47         return;
48
49     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
50     size = sizeof(buf);
51     GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
52     user = (PTOKEN_USER)buf;
53     pConvertSidToStringSidA(user->User.Sid, usersid);
54 }
55
56 /* RegDeleteTreeW from dlls/advapi32/registry.c */
57 LSTATUS WINAPI package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
58 {
59     LONG ret;
60     DWORD dwMaxSubkeyLen, dwMaxValueLen;
61     DWORD dwMaxLen, dwSize;
62     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
63     HKEY hSubKey = hKey;
64
65     if(lpszSubKey)
66     {
67         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
68         if (ret) return ret;
69     }
70
71     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
72             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
73     if (ret) goto cleanup;
74
75     dwMaxSubkeyLen++;
76     dwMaxValueLen++;
77     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
78     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
79     {
80         /* Name too big: alloc a buffer for it */
81         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
82         {
83             ret = ERROR_NOT_ENOUGH_MEMORY;
84             goto cleanup;
85         }
86     }
87
88     /* Recursively delete all the subkeys */
89     while (TRUE)
90     {
91         dwSize = dwMaxLen;
92         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
93                           NULL, NULL, NULL)) break;
94
95         ret = package_RegDeleteTreeW(hSubKey, lpszName);
96         if (ret) goto cleanup;
97     }
98
99     if (lpszSubKey)
100         ret = RegDeleteKeyW(hKey, lpszSubKey);
101     else
102         while (TRUE)
103         {
104             dwSize = dwMaxLen;
105             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
106                   NULL, NULL, NULL, NULL)) break;
107
108             ret = RegDeleteValueW(hKey, lpszName);
109             if (ret) goto cleanup;
110         }
111
112 cleanup:
113     if (lpszName != szNameBuf)
114         HeapFree(GetProcessHeap(), 0, lpszName);
115     if(lpszSubKey)
116         RegCloseKey(hSubKey);
117     return ret;
118 }
119
120 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
121 {
122     DWORD i,n=1;
123     GUID guid;
124
125     if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
126         return FALSE;
127
128     for(i=0; i<8; i++)
129         out[7-i] = in[n++];
130     n++;
131     for(i=0; i<4; i++)
132         out[11-i] = in[n++];
133     n++;
134     for(i=0; i<4; i++)
135         out[15-i] = in[n++];
136     n++;
137     for(i=0; i<2; i++)
138     {
139         out[17+i*2] = in[n++];
140         out[16+i*2] = in[n++];
141     }
142     n++;
143     for( ; i<8; i++)
144     {
145         out[17+i*2] = in[n++];
146         out[16+i*2] = in[n++];
147     }
148     out[32]=0;
149     return TRUE;
150 }
151
152 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
153                                LPCSTR guid, LPSTR usersid, BOOL dir)
154 {
155     WCHAR guidW[MAX_PATH];
156     WCHAR squashedW[MAX_PATH];
157     CHAR squashed[MAX_PATH];
158     CHAR comppath[MAX_PATH];
159     CHAR prodpath[MAX_PATH];
160     CHAR path[MAX_PATH];
161     LPCSTR prod = NULL;
162     HKEY hkey;
163
164     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
165     squash_guid(guidW, squashedW);
166     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
167
168     if (context == MSIINSTALLCONTEXT_MACHINE)
169     {
170         prod = "3D0DAE300FACA1300AD792060BCDAA92";
171         sprintf(comppath,
172                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
173                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
174         lstrcpyA(prodpath,
175                  "SOFTWARE\\Classes\\Installer\\"
176                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
177     }
178     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
179     {
180         prod = "7D2F387510109040002000060BECB6AB";
181         sprintf(comppath,
182                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
183                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
184         sprintf(prodpath,
185                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
186                 "Installer\\%s\\Installer\\Products\\"
187                 "7D2F387510109040002000060BECB6AB", usersid);
188     }
189     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
190     {
191         prod = "7D2F387510109040002000060BECB6AB";
192         sprintf(comppath,
193                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
194                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
195         sprintf(prodpath,
196                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
197                 "Installer\\Managed\\%s\\Installer\\Products\\"
198                 "7D2F387510109040002000060BECB6AB", usersid);
199     }
200
201     RegCreateKeyA(HKEY_LOCAL_MACHINE, comppath, &hkey);
202
203     lstrcpyA(path, CURR_DIR);
204     lstrcatA(path, "\\");
205     if (!dir) lstrcatA(path, filename);
206
207     RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
208     RegCloseKey(hkey);
209
210     RegCreateKeyA(HKEY_LOCAL_MACHINE, prodpath, &hkey);
211     RegCloseKey(hkey);
212 }
213
214 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
215 {
216     WCHAR guidW[MAX_PATH];
217     WCHAR squashedW[MAX_PATH];
218     WCHAR substrW[MAX_PATH];
219     CHAR squashed[MAX_PATH];
220     CHAR comppath[MAX_PATH];
221     CHAR prodpath[MAX_PATH];
222
223     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
224     squash_guid(guidW, squashedW);
225     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
226
227     if (context == MSIINSTALLCONTEXT_MACHINE)
228     {
229         sprintf(comppath,
230                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
231                 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
232         lstrcpyA(prodpath,
233                  "SOFTWARE\\Classes\\Installer\\"
234                  "Products\\3D0DAE300FACA1300AD792060BCDAA92");
235     }
236     else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
237     {
238         sprintf(comppath,
239                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
240                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
241         sprintf(prodpath,
242                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
243                 "Installer\\%s\\Installer\\Products\\"
244                 "7D2F387510109040002000060BECB6AB", usersid);
245     }
246     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
247     {
248         sprintf(comppath,
249                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
250                 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
251         sprintf(prodpath,
252                 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
253                 "Installer\\Managed\\%s\\Installer\\Products\\"
254                 "7D2F387510109040002000060BECB6AB", usersid);
255     }
256
257     MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
258     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
259
260     MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
261     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
262 }
263
264 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
265 {
266     MSIHANDLE hview = 0;
267     UINT r, ret;
268
269     /* open a select query */
270     r = MsiDatabaseOpenView(hdb, query, &hview);
271     if (r != ERROR_SUCCESS)
272         return r;
273     r = MsiViewExecute(hview, 0);
274     if (r != ERROR_SUCCESS)
275         return r;
276     ret = MsiViewFetch(hview, phrec);
277     r = MsiViewClose(hview);
278     if (r != ERROR_SUCCESS)
279         return r;
280     r = MsiCloseHandle(hview);
281     if (r != ERROR_SUCCESS)
282         return r;
283     return ret;
284 }
285
286 static UINT run_query( MSIHANDLE hdb, const char *query )
287 {
288     MSIHANDLE hview = 0;
289     UINT r;
290
291     r = MsiDatabaseOpenView(hdb, query, &hview);
292     if( r != ERROR_SUCCESS )
293         return r;
294
295     r = MsiViewExecute(hview, 0);
296     if( r == ERROR_SUCCESS )
297         r = MsiViewClose(hview);
298     MsiCloseHandle(hview);
299     return r;
300 }
301
302 static UINT create_component_table( MSIHANDLE hdb )
303 {
304     return run_query( hdb,
305             "CREATE TABLE `Component` ( "
306             "`Component` CHAR(72) NOT NULL, "
307             "`ComponentId` CHAR(38), "
308             "`Directory_` CHAR(72) NOT NULL, "
309             "`Attributes` SHORT NOT NULL, "
310             "`Condition` CHAR(255), "
311             "`KeyPath` CHAR(72) "
312             "PRIMARY KEY `Component`)" );
313 }
314
315 static UINT create_feature_table( MSIHANDLE hdb )
316 {
317     return run_query( hdb,
318             "CREATE TABLE `Feature` ( "
319             "`Feature` CHAR(38) NOT NULL, "
320             "`Feature_Parent` CHAR(38), "
321             "`Title` CHAR(64), "
322             "`Description` CHAR(255), "
323             "`Display` SHORT NOT NULL, "
324             "`Level` SHORT NOT NULL, "
325             "`Directory_` CHAR(72), "
326             "`Attributes` SHORT NOT NULL "
327             "PRIMARY KEY `Feature`)" );
328 }
329
330 static UINT create_feature_components_table( MSIHANDLE hdb )
331 {
332     return run_query( hdb,
333             "CREATE TABLE `FeatureComponents` ( "
334             "`Feature_` CHAR(38) NOT NULL, "
335             "`Component_` CHAR(72) NOT NULL "
336             "PRIMARY KEY `Feature_`, `Component_` )" );
337 }
338
339 static UINT create_file_table( MSIHANDLE hdb )
340 {
341     return run_query( hdb,
342             "CREATE TABLE `File` ("
343             "`File` CHAR(72) NOT NULL, "
344             "`Component_` CHAR(72) NOT NULL, "
345             "`FileName` CHAR(255) NOT NULL, "
346             "`FileSize` LONG NOT NULL, "
347             "`Version` CHAR(72), "
348             "`Language` CHAR(20), "
349             "`Attributes` SHORT, "
350             "`Sequence` SHORT NOT NULL "
351             "PRIMARY KEY `File`)" );
352 }
353
354 static UINT create_remove_file_table( MSIHANDLE hdb )
355 {
356     return run_query( hdb,
357             "CREATE TABLE `RemoveFile` ("
358             "`FileKey` CHAR(72) NOT NULL, "
359             "`Component_` CHAR(72) NOT NULL, "
360             "`FileName` CHAR(255) LOCALIZABLE, "
361             "`DirProperty` CHAR(72) NOT NULL, "
362             "`InstallMode` SHORT NOT NULL "
363             "PRIMARY KEY `FileKey`)" );
364 }
365
366 static UINT create_appsearch_table( MSIHANDLE hdb )
367 {
368     return run_query( hdb,
369             "CREATE TABLE `AppSearch` ("
370             "`Property` CHAR(72) NOT NULL, "
371             "`Signature_` CHAR(72) NOT NULL "
372             "PRIMARY KEY `Property`, `Signature_`)" );
373 }
374
375 static UINT create_reglocator_table( MSIHANDLE hdb )
376 {
377     return run_query( hdb,
378             "CREATE TABLE `RegLocator` ("
379             "`Signature_` CHAR(72) NOT NULL, "
380             "`Root` SHORT NOT NULL, "
381             "`Key` CHAR(255) NOT NULL, "
382             "`Name` CHAR(255), "
383             "`Type` SHORT "
384             "PRIMARY KEY `Signature_`)" );
385 }
386
387 static UINT create_signature_table( MSIHANDLE hdb )
388 {
389     return run_query( hdb,
390             "CREATE TABLE `Signature` ("
391             "`Signature` CHAR(72) NOT NULL, "
392             "`FileName` CHAR(255) NOT NULL, "
393             "`MinVersion` CHAR(20), "
394             "`MaxVersion` CHAR(20), "
395             "`MinSize` LONG, "
396             "`MaxSize` LONG, "
397             "`MinDate` LONG, "
398             "`MaxDate` LONG, "
399             "`Languages` CHAR(255) "
400             "PRIMARY KEY `Signature`)" );
401 }
402
403 static UINT create_launchcondition_table( MSIHANDLE hdb )
404 {
405     return run_query( hdb,
406             "CREATE TABLE `LaunchCondition` ("
407             "`Condition` CHAR(255) NOT NULL, "
408             "`Description` CHAR(255) NOT NULL "
409             "PRIMARY KEY `Condition`)" );
410 }
411
412 static UINT create_property_table( MSIHANDLE hdb )
413 {
414     return run_query( hdb,
415             "CREATE TABLE `Property` ("
416             "`Property` CHAR(72) NOT NULL, "
417             "`Value` CHAR(0) "
418             "PRIMARY KEY `Property`)" );
419 }
420
421 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
422 {
423     return run_query( hdb,
424             "CREATE TABLE `InstallExecuteSequence` ("
425             "`Action` CHAR(72) NOT NULL, "
426             "`Condition` CHAR(255), "
427             "`Sequence` SHORT "
428             "PRIMARY KEY `Action`)" );
429 }
430
431 static UINT create_media_table( MSIHANDLE hdb )
432 {
433     return run_query( hdb,
434             "CREATE TABLE `Media` ("
435             "`DiskId` SHORT NOT NULL, "
436             "`LastSequence` SHORT NOT NULL, "
437             "`DiskPrompt` CHAR(64), "
438             "`Cabinet` CHAR(255), "
439             "`VolumeLabel` CHAR(32), "
440             "`Source` CHAR(72) "
441             "PRIMARY KEY `DiskId`)" );
442 }
443
444 static UINT create_ccpsearch_table( MSIHANDLE hdb )
445 {
446     return run_query( hdb,
447             "CREATE TABLE `CCPSearch` ("
448             "`Signature_` CHAR(72) NOT NULL "
449             "PRIMARY KEY `Signature_`)" );
450 }
451
452 static UINT create_drlocator_table( MSIHANDLE hdb )
453 {
454     return run_query( hdb,
455             "CREATE TABLE `DrLocator` ("
456             "`Signature_` CHAR(72) NOT NULL, "
457             "`Parent` CHAR(72), "
458             "`Path` CHAR(255), "
459             "`Depth` SHORT "
460             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
461 }
462
463 static UINT create_complocator_table( MSIHANDLE hdb )
464 {
465     return run_query( hdb,
466             "CREATE TABLE `CompLocator` ("
467             "`Signature_` CHAR(72) NOT NULL, "
468             "`ComponentId` CHAR(38) NOT NULL, "
469             "`Type` SHORT "
470             "PRIMARY KEY `Signature_`)" );
471 }
472
473 static UINT create_inilocator_table( MSIHANDLE hdb )
474 {
475     return run_query( hdb,
476             "CREATE TABLE `IniLocator` ("
477             "`Signature_` CHAR(72) NOT NULL, "
478             "`FileName` CHAR(255) NOT NULL, "
479             "`Section` CHAR(96)NOT NULL, "
480             "`Key` CHAR(128)NOT NULL, "
481             "`Field` SHORT, "
482             "`Type` SHORT "
483             "PRIMARY KEY `Signature_`)" );
484 }
485
486 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
487 {
488     char insert[] = "INSERT INTO `Component`  "
489             "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
490             "VALUES( %s )";
491     char *query;
492     UINT sz, r;
493
494     sz = strlen(values) + sizeof insert;
495     query = HeapAlloc(GetProcessHeap(),0,sz);
496     sprintf(query,insert,values);
497     r = run_query( hdb, query );
498     HeapFree(GetProcessHeap(), 0, query);
499     return r;
500 }
501
502 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
503 {
504     char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
505     char *query;
506     UINT sz, r;
507
508     sz = strlen(values) + sizeof insert;
509     query = HeapAlloc(GetProcessHeap(),0,sz);
510     sprintf(query,insert,values);
511     r = run_query( hdb, query );
512     HeapFree(GetProcessHeap(), 0, query);
513     return r;
514 }
515
516 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
517 {
518     char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
519                     "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
520     char *query;
521     UINT sz, r;
522
523     sz = strlen(values) + sizeof insert;
524     query = HeapAlloc(GetProcessHeap(),0,sz);
525     sprintf(query,insert,values);
526     r = run_query( hdb, query );
527     HeapFree(GetProcessHeap(), 0, query);
528     return r;
529 }
530
531 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
532 {
533     char insert[] = "INSERT INTO `FeatureComponents` "
534             "(`Feature_`, `Component_`) "
535             "VALUES( %s )";
536     char *query;
537     UINT sz, r;
538
539     sz = strlen(values) + sizeof insert;
540     query = HeapAlloc(GetProcessHeap(),0,sz);
541     sprintf(query,insert,values);
542     r = run_query( hdb, query );
543     HeapFree(GetProcessHeap(), 0, query);
544     return r;
545 }
546
547 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
548 {
549     char insert[] = "INSERT INTO `File` "
550             "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
551             "VALUES( %s )";
552     char *query;
553     UINT sz, r;
554
555     sz = strlen(values) + sizeof insert;
556     query = HeapAlloc(GetProcessHeap(),0,sz);
557     sprintf(query,insert,values);
558     r = run_query( hdb, query );
559     HeapFree(GetProcessHeap(), 0, query);
560     return r;
561 }
562
563 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
564 {
565     char insert[] = "INSERT INTO `AppSearch` "
566             "(`Property`, `Signature_`) "
567             "VALUES( %s )";
568     char *query;
569     UINT sz, r;
570
571     sz = strlen(values) + sizeof insert;
572     query = HeapAlloc(GetProcessHeap(),0,sz);
573     sprintf(query,insert,values);
574     r = run_query( hdb, query );
575     HeapFree(GetProcessHeap(), 0, query);
576     return r;
577 }
578
579 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
580 {
581     char insert[] = "INSERT INTO `RegLocator` "
582             "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
583             "VALUES( %s )";
584     char *query;
585     UINT sz, r;
586
587     sz = strlen(values) + sizeof insert;
588     query = HeapAlloc(GetProcessHeap(),0,sz);
589     sprintf(query,insert,values);
590     r = run_query( hdb, query );
591     HeapFree(GetProcessHeap(), 0, query);
592     return r;
593 }
594
595 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
596 {
597     char insert[] = "INSERT INTO `Signature` "
598             "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
599             " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
600             "VALUES( %s )";
601     char *query;
602     UINT sz, r;
603
604     sz = strlen(values) + sizeof insert;
605     query = HeapAlloc(GetProcessHeap(),0,sz);
606     sprintf(query,insert,values);
607     r = run_query( hdb, query );
608     HeapFree(GetProcessHeap(), 0, query);
609     return r;
610 }
611
612 static UINT add_launchcondition_entry( MSIHANDLE hdb, const char *values )
613 {
614     char insert[] = "INSERT INTO `LaunchCondition` "
615             "(`Condition`, `Description`) "
616             "VALUES( %s )";
617     char *query;
618     UINT sz, r;
619
620     sz = strlen(values) + sizeof insert;
621     query = HeapAlloc(GetProcessHeap(),0,sz);
622     sprintf(query,insert,values);
623     r = run_query( hdb, query );
624     HeapFree(GetProcessHeap(), 0, query);
625     return r;
626 }
627
628 static UINT add_property_entry( MSIHANDLE hdb, const char *values )
629 {
630     char insert[] = "INSERT INTO `Property` "
631             "(`Property`, `Value`) "
632             "VALUES( %s )";
633     char *query;
634     UINT sz, r;
635
636     sz = strlen(values) + sizeof insert;
637     query = HeapAlloc(GetProcessHeap(),0,sz);
638     sprintf(query,insert,values);
639     r = run_query( hdb, query );
640     HeapFree(GetProcessHeap(), 0, query);
641     return r;
642 }
643
644 static UINT add_install_execute_sequence_entry( MSIHANDLE hdb, const char *values )
645 {
646     char insert[] = "INSERT INTO `InstallExecuteSequence` "
647             "(`Action`, `Condition`, `Sequence`) "
648             "VALUES( %s )";
649     char *query;
650     UINT sz, r;
651
652     sz = strlen(values) + sizeof insert;
653     query = HeapAlloc(GetProcessHeap(),0,sz);
654     sprintf(query,insert,values);
655     r = run_query( hdb, query );
656     HeapFree(GetProcessHeap(), 0, query);
657     return r;
658 }
659
660 static UINT add_media_entry( MSIHANDLE hdb, const char *values )
661 {
662     char insert[] = "INSERT INTO `Media` "
663             "(`DiskId`, `LastSequence`, `DiskPrompt`, `Cabinet`, `VolumeLabel`, `Source`) "
664             "VALUES( %s )";
665     char *query;
666     UINT sz, r;
667
668     sz = strlen(values) + sizeof insert;
669     query = HeapAlloc(GetProcessHeap(),0,sz);
670     sprintf(query,insert,values);
671     r = run_query( hdb, query );
672     HeapFree(GetProcessHeap(), 0, query);
673     return r;
674 }
675
676 static UINT add_ccpsearch_entry( MSIHANDLE hdb, const char *values )
677 {
678     char insert[] = "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )";
679     char *query;
680     UINT sz, r;
681
682     sz = strlen(values) + sizeof insert;
683     query = HeapAlloc(GetProcessHeap(),0,sz);
684     sprintf(query,insert,values);
685     r = run_query( hdb, query );
686     HeapFree(GetProcessHeap(), 0, query);
687     return r;
688 }
689
690 static UINT add_drlocator_entry( MSIHANDLE hdb, const char *values )
691 {
692     char insert[] = "INSERT INTO `DrLocator` "
693             "(`Signature_`, `Parent`, `Path`, `Depth`) "
694             "VALUES( %s )";
695     char *query;
696     UINT sz, r;
697
698     sz = strlen(values) + sizeof insert;
699     query = HeapAlloc(GetProcessHeap(),0,sz);
700     sprintf(query,insert,values);
701     r = run_query( hdb, query );
702     HeapFree(GetProcessHeap(), 0, query);
703     return r;
704 }
705
706 static UINT add_complocator_entry( MSIHANDLE hdb, const char *values )
707 {
708     char insert[] = "INSERT INTO `CompLocator` "
709             "(`Signature_`, `ComponentId`, `Type`) "
710             "VALUES( %s )";
711     char *query;
712     UINT sz, r;
713
714     sz = strlen(values) + sizeof insert;
715     query = HeapAlloc(GetProcessHeap(),0,sz);
716     sprintf(query,insert,values);
717     r = run_query( hdb, query );
718     HeapFree(GetProcessHeap(), 0, query);
719     return r;
720 }
721
722 static UINT add_inilocator_entry( MSIHANDLE hdb, const char *values )
723 {
724     char insert[] = "INSERT INTO `IniLocator` "
725             "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
726             "VALUES( %s )";
727     char *query;
728     UINT sz, r;
729
730     sz = strlen(values) + sizeof insert;
731     query = HeapAlloc(GetProcessHeap(),0,sz);
732     sprintf(query,insert,values);
733     r = run_query( hdb, query );
734     HeapFree(GetProcessHeap(), 0, query);
735     return r;
736 }
737
738 static UINT set_summary_info(MSIHANDLE hdb)
739 {
740     UINT res;
741     MSIHANDLE suminfo;
742
743     /* build summary info */
744     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
745     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
746
747     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
748                         "Installation Database");
749     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
750
751     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
752                         "Installation Database");
753     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
754
755     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
756                         "Wine Hackers");
757     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
758
759     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
760                     ";1033");
761     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
762
763     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
764                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
765     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
766
767     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
768     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
769
770     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
771     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
772
773     res = MsiSummaryInfoPersist(suminfo);
774     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
775
776     res = MsiCloseHandle( suminfo);
777     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
778
779     return res;
780 }
781
782
783 static MSIHANDLE create_package_db(void)
784 {
785     MSIHANDLE hdb = 0;
786     UINT res;
787
788     DeleteFile(msifile);
789
790     /* create an empty database */
791     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
792     ok( res == ERROR_SUCCESS , "Failed to create database\n" );
793     if( res != ERROR_SUCCESS )
794         return hdb;
795
796     res = MsiDatabaseCommit( hdb );
797     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
798
799     res = set_summary_info(hdb);
800
801     res = run_query( hdb,
802             "CREATE TABLE `Directory` ( "
803             "`Directory` CHAR(255) NOT NULL, "
804             "`Directory_Parent` CHAR(255), "
805             "`DefaultDir` CHAR(255) NOT NULL "
806             "PRIMARY KEY `Directory`)" );
807     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
808
809     return hdb;
810 }
811
812 static MSIHANDLE package_from_db(MSIHANDLE hdb)
813 {
814     UINT res;
815     CHAR szPackage[10];
816     MSIHANDLE hPackage;
817
818     sprintf(szPackage,"#%li",hdb);
819     res = MsiOpenPackage(szPackage,&hPackage);
820     if (res != ERROR_SUCCESS)
821         return 0;
822
823     res = MsiCloseHandle(hdb);
824     if (res != ERROR_SUCCESS)
825         return 0;
826
827     return hPackage;
828 }
829
830 static void create_test_file(const CHAR *name)
831 {
832     HANDLE file;
833     DWORD written;
834
835     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
836     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
837     WriteFile(file, name, strlen(name), &written, NULL);
838     WriteFile(file, "\n", strlen("\n"), &written, NULL);
839     CloseHandle(file);
840 }
841
842 typedef struct _tagVS_VERSIONINFO
843 {
844     WORD wLength;
845     WORD wValueLength;
846     WORD wType;
847     WCHAR szKey[1];
848     WORD wPadding1[1];
849     VS_FIXEDFILEINFO Value;
850     WORD wPadding2[1];
851     WORD wChildren[1];
852 } VS_VERSIONINFO;
853
854 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
855 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
856
857 static void create_file_with_version(const CHAR *name, LONG ms, LONG ls)
858 {
859     VS_VERSIONINFO *pVerInfo;
860     VS_FIXEDFILEINFO *pFixedInfo;
861     LPBYTE buffer, ofs;
862     CHAR path[MAX_PATH];
863     DWORD handle, size;
864     HANDLE resource;
865
866     GetSystemDirectory(path, MAX_PATH);
867     lstrcatA(path, "\\kernel32.dll");
868
869     CopyFileA(path, name, FALSE);
870
871     size = GetFileVersionInfoSize(path, &handle);
872     buffer = HeapAlloc(GetProcessHeap(), 0, size);
873
874     GetFileVersionInfoA(path, 0, size, buffer);
875
876     pVerInfo = (VS_VERSIONINFO *)buffer;
877     ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
878     pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
879
880     pFixedInfo->dwFileVersionMS = ms;
881     pFixedInfo->dwFileVersionLS = ls;
882     pFixedInfo->dwProductVersionMS = ms;
883     pFixedInfo->dwProductVersionLS = ls;
884
885     resource = BeginUpdateResource(name, FALSE);
886     if (!resource)
887         goto done;
888
889     UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
890                    MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size);
891     EndUpdateResource(resource, FALSE);
892
893 done:
894     HeapFree(GetProcessHeap(), 0, buffer);
895 }
896
897 static void test_createpackage(void)
898 {
899     MSIHANDLE hPackage = 0;
900     UINT res;
901
902     hPackage = package_from_db(create_package_db());
903     ok( hPackage != 0, " Failed to create package\n");
904
905     res = MsiCloseHandle( hPackage);
906     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
907     DeleteFile(msifile);
908 }
909
910 static void test_doaction( void )
911 {
912     MSIHANDLE hpkg;
913     UINT r;
914
915     r = MsiDoAction( -1, NULL );
916     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
917
918     hpkg = package_from_db(create_package_db());
919     ok( hpkg, "failed to create package\n");
920
921     r = MsiDoAction(hpkg, NULL);
922     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
923
924     r = MsiDoAction(0, "boo");
925     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
926
927     r = MsiDoAction(hpkg, "boo");
928     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
929
930     MsiCloseHandle( hpkg );
931     DeleteFile(msifile);
932 }
933
934 static void test_gettargetpath_bad(void)
935 {
936     char buffer[0x80];
937     MSIHANDLE hpkg;
938     DWORD sz;
939     UINT r;
940
941     hpkg = package_from_db(create_package_db());
942     ok( hpkg, "failed to create package\n");
943
944     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
945     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
946
947     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
948     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
949
950     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
951     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
952
953     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
954     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
955
956     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
957     ok( r == ERROR_DIRECTORY, "wrong return val\n");
958
959     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
960     ok( r == ERROR_DIRECTORY, "wrong return val\n");
961
962     MsiCloseHandle( hpkg );
963     DeleteFile(msifile);
964 }
965
966 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
967 {
968     UINT r;
969     DWORD size;
970     MSIHANDLE rec;
971
972     rec = MsiCreateRecord( 1 );
973     ok(rec, "MsiCreate record failed\n");
974
975     r = MsiRecordSetString( rec, 0, file );
976     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
977
978     size = MAX_PATH;
979     r = MsiFormatRecord( hpkg, rec, buff, &size );
980     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
981
982     MsiCloseHandle( rec );
983 }
984
985 static void test_settargetpath(void)
986 {
987     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
988     DWORD sz;
989     MSIHANDLE hpkg;
990     UINT r;
991     MSIHANDLE hdb;
992
993     hdb = create_package_db();
994     ok ( hdb, "failed to create package database\n" );
995
996     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
997     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
998
999     r = create_component_table( hdb );
1000     ok( r == S_OK, "cannot create Component table: %d\n", r );
1001
1002     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1003     ok( r == S_OK, "cannot add dummy component: %d\n", r );
1004
1005     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1006     ok( r == S_OK, "cannot add test component: %d\n", r );
1007
1008     r = create_feature_table( hdb );
1009     ok( r == S_OK, "cannot create Feature table: %d\n", r );
1010
1011     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1012     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1013
1014     r = create_feature_components_table( hdb );
1015     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1016
1017     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1018     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1019
1020     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1021     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1022
1023     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1024     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1025
1026     r = create_file_table( hdb );
1027     ok( r == S_OK, "cannot create File table: %d\n", r );
1028
1029     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1030     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1031
1032     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1033     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1034
1035     hpkg = package_from_db( hdb );
1036     ok( hpkg, "failed to create package\n");
1037
1038     r = MsiDoAction( hpkg, "CostInitialize");
1039     ok( r == ERROR_SUCCESS, "cost init failed\n");
1040
1041     r = MsiDoAction( hpkg, "FileCost");
1042     ok( r == ERROR_SUCCESS, "file cost failed\n");
1043
1044     r = MsiDoAction( hpkg, "CostFinalize");
1045     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1046
1047     r = MsiSetTargetPath( 0, NULL, NULL );
1048     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1049
1050     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1051     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1052
1053     r = MsiSetTargetPath( hpkg, "boo", NULL );
1054     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1055
1056     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1057     ok( r == ERROR_DIRECTORY, "wrong return val\n");
1058
1059     sz = sizeof tempdir - 1;
1060     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1061     sprintf( file, "%srootfile.txt", tempdir );
1062     query_file_path( hpkg, "[#RootFile]", buffer );
1063     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1064     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1065
1066     GetTempFileName( tempdir, "_wt", 0, buffer );
1067     sprintf( tempdir, "%s\\subdir", buffer );
1068
1069     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1070     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1071         "MsiSetTargetPath on file returned %d\n", r );
1072
1073     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1074     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1075         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1076
1077     DeleteFile( buffer );
1078
1079     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1080     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1081
1082     r = GetFileAttributes( buffer );
1083     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1084
1085     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1086     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1087
1088     sz = sizeof buffer - 1;
1089     lstrcat( tempdir, "\\" );
1090     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1091     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1092     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1093
1094     sprintf( file, "%srootfile.txt", tempdir );
1095     query_file_path( hpkg, "[#RootFile]", buffer );
1096     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1097
1098     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1099     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1100
1101     query_file_path( hpkg, "[#TestFile]", buffer );
1102     ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1103         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1104
1105     sz = sizeof buffer - 1;
1106     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1107     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1108     ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1109
1110     MsiCloseHandle( hpkg );
1111 }
1112
1113 static void test_condition(void)
1114 {
1115     MSICONDITION r;
1116     MSIHANDLE hpkg;
1117
1118     hpkg = package_from_db(create_package_db());
1119     ok( hpkg, "failed to create package\n");
1120
1121     r = MsiEvaluateCondition(0, NULL);
1122     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1123
1124     r = MsiEvaluateCondition(hpkg, NULL);
1125     ok( r == MSICONDITION_NONE, "wrong return val\n");
1126
1127     r = MsiEvaluateCondition(hpkg, "");
1128     ok( r == MSICONDITION_NONE, "wrong return val\n");
1129
1130     r = MsiEvaluateCondition(hpkg, "1");
1131     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1132
1133     r = MsiEvaluateCondition(hpkg, "0");
1134     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1135
1136     r = MsiEvaluateCondition(hpkg, "-1");
1137     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1138
1139     r = MsiEvaluateCondition(hpkg, "0 = 0");
1140     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1141
1142     r = MsiEvaluateCondition(hpkg, "0 <> 0");
1143     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1144
1145     r = MsiEvaluateCondition(hpkg, "0 = 1");
1146     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1147
1148     r = MsiEvaluateCondition(hpkg, "0 > 1");
1149     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1150
1151     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1152     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1153
1154     r = MsiEvaluateCondition(hpkg, "1 > 1");
1155     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1156
1157     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1158     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1159
1160     r = MsiEvaluateCondition(hpkg, "0 >= 1");
1161     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1162
1163     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1164     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1165
1166     r = MsiEvaluateCondition(hpkg, "1 >= 1");
1167     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1168
1169     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1170     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1171
1172     r = MsiEvaluateCondition(hpkg, "0 < 1");
1173     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1174
1175     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1176     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1177
1178     r = MsiEvaluateCondition(hpkg, "1 < 1");
1179     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1180
1181     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1182     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1183
1184     r = MsiEvaluateCondition(hpkg, "0 <= 1");
1185     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1186
1187     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1188     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1189
1190     r = MsiEvaluateCondition(hpkg, "1 <= 1");
1191     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1192
1193     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1194     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1195
1196     r = MsiEvaluateCondition(hpkg, "0 >=");
1197     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1198
1199     r = MsiEvaluateCondition(hpkg, " ");
1200     ok( r == MSICONDITION_NONE, "wrong return val\n");
1201
1202     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1203     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1204
1205     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1206     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1207
1208     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1209     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1210
1211     r = MsiEvaluateCondition(hpkg, "not 0");
1212     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1213
1214     r = MsiEvaluateCondition(hpkg, "not LicView");
1215     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1216
1217     r = MsiEvaluateCondition(hpkg, "not \"A\"");
1218     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1219
1220     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1221     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1222
1223     r = MsiEvaluateCondition(hpkg, "\"0\"");
1224     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1225
1226     r = MsiEvaluateCondition(hpkg, "1 and 2");
1227     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1228
1229     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1230     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1231
1232     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1233     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1234
1235     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1236     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1237
1238     r = MsiEvaluateCondition(hpkg, "(0)");
1239     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1240
1241     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1242     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1243
1244     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1245     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1246
1247     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1248     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1249
1250     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1251     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1252
1253     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1254     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1255
1256     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1257     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258
1259     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1260     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1261
1262     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1263     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1264
1265     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1266     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1267
1268     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1269     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1270
1271     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1272     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1275     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1276
1277     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1278     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1279
1280     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1281     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1282
1283     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1284     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1285
1286     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1287     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1288
1289     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1290     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1291
1292     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1293     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1296     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1297
1298     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1299     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300
1301     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1302     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1305     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1306
1307     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1308     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1309
1310     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1311     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1312
1313     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1314     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1315
1316     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1317     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1318
1319     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1320     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1321
1322     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1323     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1324
1325     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1326     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1327
1328     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1329     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1330
1331     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1332     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1333
1334     MsiSetProperty(hpkg, "mm", "5" );
1335
1336     r = MsiEvaluateCondition(hpkg, "mm = 5");
1337     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1338
1339     r = MsiEvaluateCondition(hpkg, "mm < 6");
1340     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1341
1342     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1343     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1344
1345     r = MsiEvaluateCondition(hpkg, "mm > 4");
1346     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1347
1348     r = MsiEvaluateCondition(hpkg, "mm < 12");
1349     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1350
1351     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1352     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1353
1354     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1355     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1356
1357     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1358     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1359
1360     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1361     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1362
1363     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1364     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1365
1366     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1367     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1368
1369     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1370     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1371
1372     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1373     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1374
1375     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1376     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1377
1378     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1379     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1380
1381     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1382     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1383
1384     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1385     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1386
1387     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1388     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1389
1390     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1391     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1392
1393     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1394     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1395
1396     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1397     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1398
1399     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1400     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1401
1402     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1403     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1404
1405     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1406     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1407
1408     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1409     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1410
1411     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1412     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1413
1414     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1415     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1416
1417     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1418     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1419
1420     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1421     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1422
1423     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1424     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1425
1426     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1427     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429     MsiSetProperty(hpkg, "bandalmael", "0" );
1430     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1431     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1432
1433     MsiSetProperty(hpkg, "bandalmael", "" );
1434     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1435     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1436
1437     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1438     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1439     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1440
1441     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1442     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1443     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1444
1445     MsiSetProperty(hpkg, "bandalmael", "0 " );
1446     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1447     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1448
1449     MsiSetProperty(hpkg, "bandalmael", "-0" );
1450     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1451     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1452
1453     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1454     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1455     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1456
1457     MsiSetProperty(hpkg, "bandalmael", "--0" );
1458     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1459     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1460
1461     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1462     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1463     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1464
1465     MsiSetProperty(hpkg, "bandalmael", "-" );
1466     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1467     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1468
1469     MsiSetProperty(hpkg, "bandalmael", "+0" );
1470     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1471     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1472
1473     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1474     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1475     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1476     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1477     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1478
1479     MsiSetProperty(hpkg, "one", "hi");
1480     MsiSetProperty(hpkg, "two", "hithere");
1481     r = MsiEvaluateCondition(hpkg, "one >< two");
1482     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1483
1484     MsiSetProperty(hpkg, "one", "hithere");
1485     MsiSetProperty(hpkg, "two", "hi");
1486     r = MsiEvaluateCondition(hpkg, "one >< two");
1487     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488
1489     MsiSetProperty(hpkg, "one", "hello");
1490     MsiSetProperty(hpkg, "two", "hi");
1491     r = MsiEvaluateCondition(hpkg, "one >< two");
1492     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1493
1494     MsiSetProperty(hpkg, "one", "hellohithere");
1495     MsiSetProperty(hpkg, "two", "hi");
1496     r = MsiEvaluateCondition(hpkg, "one >< two");
1497     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1498
1499     MsiSetProperty(hpkg, "one", "");
1500     MsiSetProperty(hpkg, "two", "hi");
1501     r = MsiEvaluateCondition(hpkg, "one >< two");
1502     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1503
1504     MsiSetProperty(hpkg, "one", "hi");
1505     MsiSetProperty(hpkg, "two", "");
1506     r = MsiEvaluateCondition(hpkg, "one >< two");
1507     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1508
1509     MsiSetProperty(hpkg, "one", "");
1510     MsiSetProperty(hpkg, "two", "");
1511     r = MsiEvaluateCondition(hpkg, "one >< two");
1512     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1513
1514     MsiSetProperty(hpkg, "one", "1234");
1515     MsiSetProperty(hpkg, "two", "1");
1516     r = MsiEvaluateCondition(hpkg, "one >< two");
1517     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1518
1519     MsiSetProperty(hpkg, "one", "one 1234");
1520     MsiSetProperty(hpkg, "two", "1");
1521     r = MsiEvaluateCondition(hpkg, "one >< two");
1522     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1523
1524     MsiSetProperty(hpkg, "one", "hithere");
1525     MsiSetProperty(hpkg, "two", "hi");
1526     r = MsiEvaluateCondition(hpkg, "one << two");
1527     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1528
1529     MsiSetProperty(hpkg, "one", "hi");
1530     MsiSetProperty(hpkg, "two", "hithere");
1531     r = MsiEvaluateCondition(hpkg, "one << two");
1532     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1533
1534     MsiSetProperty(hpkg, "one", "hi");
1535     MsiSetProperty(hpkg, "two", "hi");
1536     r = MsiEvaluateCondition(hpkg, "one << two");
1537     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1538
1539     MsiSetProperty(hpkg, "one", "abcdhithere");
1540     MsiSetProperty(hpkg, "two", "hi");
1541     r = MsiEvaluateCondition(hpkg, "one << two");
1542     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1543
1544     MsiSetProperty(hpkg, "one", "");
1545     MsiSetProperty(hpkg, "two", "hi");
1546     r = MsiEvaluateCondition(hpkg, "one << two");
1547     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1548
1549     MsiSetProperty(hpkg, "one", "hithere");
1550     MsiSetProperty(hpkg, "two", "");
1551     r = MsiEvaluateCondition(hpkg, "one << two");
1552     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1553
1554     MsiSetProperty(hpkg, "one", "");
1555     MsiSetProperty(hpkg, "two", "");
1556     r = MsiEvaluateCondition(hpkg, "one << two");
1557     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1558
1559     MsiSetProperty(hpkg, "one", "1234");
1560     MsiSetProperty(hpkg, "two", "1");
1561     r = MsiEvaluateCondition(hpkg, "one << two");
1562     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1563
1564     MsiSetProperty(hpkg, "one", "1234 one");
1565     MsiSetProperty(hpkg, "two", "1");
1566     r = MsiEvaluateCondition(hpkg, "one << two");
1567     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1568
1569     MsiSetProperty(hpkg, "one", "hithere");
1570     MsiSetProperty(hpkg, "two", "there");
1571     r = MsiEvaluateCondition(hpkg, "one >> two");
1572     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1573
1574     MsiSetProperty(hpkg, "one", "hithere");
1575     MsiSetProperty(hpkg, "two", "hi");
1576     r = MsiEvaluateCondition(hpkg, "one >> two");
1577     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1578
1579     MsiSetProperty(hpkg, "one", "there");
1580     MsiSetProperty(hpkg, "two", "hithere");
1581     r = MsiEvaluateCondition(hpkg, "one >> two");
1582     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1583
1584     MsiSetProperty(hpkg, "one", "there");
1585     MsiSetProperty(hpkg, "two", "there");
1586     r = MsiEvaluateCondition(hpkg, "one >> two");
1587     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1588
1589     MsiSetProperty(hpkg, "one", "abcdhithere");
1590     MsiSetProperty(hpkg, "two", "hi");
1591     r = MsiEvaluateCondition(hpkg, "one >> two");
1592     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1593
1594     MsiSetProperty(hpkg, "one", "");
1595     MsiSetProperty(hpkg, "two", "there");
1596     r = MsiEvaluateCondition(hpkg, "one >> two");
1597     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1598
1599     MsiSetProperty(hpkg, "one", "there");
1600     MsiSetProperty(hpkg, "two", "");
1601     r = MsiEvaluateCondition(hpkg, "one >> two");
1602     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1603
1604     MsiSetProperty(hpkg, "one", "");
1605     MsiSetProperty(hpkg, "two", "");
1606     r = MsiEvaluateCondition(hpkg, "one >> two");
1607     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1608
1609     MsiSetProperty(hpkg, "one", "1234");
1610     MsiSetProperty(hpkg, "two", "4");
1611     r = MsiEvaluateCondition(hpkg, "one >> two");
1612     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1613
1614     MsiSetProperty(hpkg, "one", "one 1234");
1615     MsiSetProperty(hpkg, "two", "4");
1616     r = MsiEvaluateCondition(hpkg, "one >> two");
1617     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1618
1619     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1620
1621     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1622     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1623
1624     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1625     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1626
1627     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1628     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1629
1630     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1631     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1632
1633     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1634     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1635
1636     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1637     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1638
1639     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1640     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1641
1642     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1643     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1644
1645     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1646     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1647
1648     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1649     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1650
1651     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1652     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1653
1654     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1655     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1656
1657     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1658     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1659
1660     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1661     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1662
1663     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1664     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1665
1666     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1667     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1668
1669     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1670     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1671
1672     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1673     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1674
1675     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1676     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1677
1678     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1679     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1680
1681     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1682     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1683
1684     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1685     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1686
1687     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1688     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1689
1690     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1691     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1692
1693     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1694     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1695
1696     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1697     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1698
1699     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1700     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1701
1702     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1703     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1704
1705     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1706     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1707
1708     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1709     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1710
1711     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1712     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1713
1714     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1715     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1716
1717     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1718     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1719
1720     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1721     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1722
1723     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1724     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1725
1726     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1727     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1728
1729     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1730     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1731
1732     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1733     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1734     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1735
1736     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1737     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1738
1739     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1740     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1741
1742     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1743     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1744
1745     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1746     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1747
1748     MsiSetProperty(hpkg, "one", "1");
1749     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1750     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1751
1752     MsiSetProperty(hpkg, "X", "5.0");
1753
1754     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1755     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1756
1757     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1758     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1759
1760     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1761     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1762
1763     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1764     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1765
1766     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1767     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1768
1769     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1770     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1771
1772     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1773     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1774
1775     /* feature doesn't exist */
1776     r = MsiEvaluateCondition(hpkg, "&nofeature");
1777     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1778
1779     MsiSetProperty(hpkg, "A", "2");
1780     MsiSetProperty(hpkg, "X", "50");
1781
1782     r = MsiEvaluateCondition(hpkg, "2 <= X");
1783     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1784
1785     r = MsiEvaluateCondition(hpkg, "A <= X");
1786     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1787
1788     r = MsiEvaluateCondition(hpkg, "A <= 50");
1789     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1790
1791     MsiSetProperty(hpkg, "X", "50val");
1792
1793     r = MsiEvaluateCondition(hpkg, "2 <= X");
1794     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1795
1796     r = MsiEvaluateCondition(hpkg, "A <= X");
1797     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1798
1799     MsiSetProperty(hpkg, "A", "7");
1800     MsiSetProperty(hpkg, "X", "50");
1801
1802     r = MsiEvaluateCondition(hpkg, "7 <= X");
1803     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1804
1805     r = MsiEvaluateCondition(hpkg, "A <= X");
1806     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1807
1808     r = MsiEvaluateCondition(hpkg, "A <= 50");
1809     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1810
1811     MsiSetProperty(hpkg, "X", "50val");
1812
1813     r = MsiEvaluateCondition(hpkg, "2 <= X");
1814     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1815
1816     r = MsiEvaluateCondition(hpkg, "A <= X");
1817     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1818
1819     MsiCloseHandle( hpkg );
1820     DeleteFile(msifile);
1821 }
1822
1823 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1824 {
1825     UINT r;
1826     DWORD sz;
1827     char buffer[2];
1828
1829     sz = sizeof buffer;
1830     strcpy(buffer,"x");
1831     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1832     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1833 }
1834
1835 static void test_props(void)
1836 {
1837     MSIHANDLE hpkg, hdb;
1838     UINT r;
1839     DWORD sz;
1840     char buffer[0x100];
1841
1842     hdb = create_package_db();
1843     r = run_query( hdb,
1844             "CREATE TABLE `Property` ( "
1845             "`Property` CHAR(255) NOT NULL, "
1846             "`Value` CHAR(255) "
1847             "PRIMARY KEY `Property`)" );
1848     ok( r == ERROR_SUCCESS , "Failed\n" );
1849
1850     r = run_query(hdb,
1851             "INSERT INTO `Property` "
1852             "(`Property`, `Value`) "
1853             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1854     ok( r == ERROR_SUCCESS , "Failed\n" );
1855
1856     hpkg = package_from_db( hdb );
1857     ok( hpkg, "failed to create package\n");
1858
1859     /* test invalid values */
1860     r = MsiGetProperty( 0, NULL, NULL, NULL );
1861     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1862
1863     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1864     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1865
1866     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1867     ok( r == ERROR_SUCCESS, "wrong return val\n");
1868
1869     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1870     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1871
1872     /* test retrieving an empty/nonexistent property */
1873     sz = sizeof buffer;
1874     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1875     ok( r == ERROR_SUCCESS, "wrong return val\n");
1876     ok( sz == 0, "wrong size returned\n");
1877
1878     check_prop_empty( hpkg, "boo");
1879     sz = 0;
1880     strcpy(buffer,"x");
1881     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1882     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1883     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1884     ok( sz == 0, "wrong size returned\n");
1885
1886     sz = 1;
1887     strcpy(buffer,"x");
1888     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1889     ok( r == ERROR_SUCCESS, "wrong return val\n");
1890     ok( buffer[0] == 0, "buffer was not changed\n");
1891     ok( sz == 0, "wrong size returned\n");
1892
1893     /* set the property to something */
1894     r = MsiSetProperty( 0, NULL, NULL );
1895     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1896
1897     r = MsiSetProperty( hpkg, NULL, NULL );
1898     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1899
1900     r = MsiSetProperty( hpkg, "", NULL );
1901     ok( r == ERROR_SUCCESS, "wrong return val\n");
1902
1903     /* try set and get some illegal property identifiers */
1904     r = MsiSetProperty( hpkg, "", "asdf" );
1905     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1906
1907     r = MsiSetProperty( hpkg, "=", "asdf" );
1908     ok( r == ERROR_SUCCESS, "wrong return val\n");
1909
1910     r = MsiSetProperty( hpkg, " ", "asdf" );
1911     ok( r == ERROR_SUCCESS, "wrong return val\n");
1912
1913     r = MsiSetProperty( hpkg, "'", "asdf" );
1914     ok( r == ERROR_SUCCESS, "wrong return val\n");
1915
1916     sz = sizeof buffer;
1917     buffer[0]=0;
1918     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1919     ok( r == ERROR_SUCCESS, "wrong return val\n");
1920     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1921
1922     /* set empty values */
1923     r = MsiSetProperty( hpkg, "boo", NULL );
1924     ok( r == ERROR_SUCCESS, "wrong return val\n");
1925     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1926
1927     r = MsiSetProperty( hpkg, "boo", "" );
1928     ok( r == ERROR_SUCCESS, "wrong return val\n");
1929     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1930
1931     /* set a non-empty value */
1932     r = MsiSetProperty( hpkg, "boo", "xyz" );
1933     ok( r == ERROR_SUCCESS, "wrong return val\n");
1934
1935     sz = 1;
1936     strcpy(buffer,"x");
1937     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1938     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1939     ok( buffer[0] == 0, "buffer was not changed\n");
1940     ok( sz == 3, "wrong size returned\n");
1941
1942     sz = 4;
1943     strcpy(buffer,"x");
1944     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1945     ok( r == ERROR_SUCCESS, "wrong return val\n");
1946     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1947     ok( sz == 3, "wrong size returned\n");
1948
1949     sz = 3;
1950     strcpy(buffer,"x");
1951     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1952     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1953     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1954     ok( sz == 3, "wrong size returned\n");
1955
1956     r = MsiSetProperty(hpkg, "SourceDir", "foo");
1957     ok( r == ERROR_SUCCESS, "wrong return val\n");
1958
1959     sz = 4;
1960     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1961     ok( r == ERROR_SUCCESS, "wrong return val\n");
1962     ok( !strcmp(buffer,""), "buffer wrong\n");
1963     ok( sz == 0, "wrong size returned\n");
1964
1965     sz = 4;
1966     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1967     ok( r == ERROR_SUCCESS, "wrong return val\n");
1968     ok( !strcmp(buffer,""), "buffer wrong\n");
1969     ok( sz == 0, "wrong size returned\n");
1970
1971     sz = 4;
1972     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1973     ok( r == ERROR_SUCCESS, "wrong return val\n");
1974     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1975     ok( sz == 3, "wrong size returned\n");
1976
1977     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1978     ok( r == ERROR_SUCCESS, "wrong return val\n");
1979
1980     sz = 0;
1981     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1982     ok( r == ERROR_SUCCESS, "return wrong\n");
1983     ok( sz == 13, "size wrong (%d)\n", sz);
1984
1985     sz = 13;
1986     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1987     ok( r == ERROR_MORE_DATA, "return wrong\n");
1988     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1989
1990     r = MsiSetProperty(hpkg, "property", "value");
1991     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1992
1993     sz = 6;
1994     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1996     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1997
1998     r = MsiSetProperty(hpkg, "property", NULL);
1999     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2000
2001     sz = 6;
2002     r = MsiGetProperty(hpkg, "property", buffer, &sz);
2003     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2004     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2005
2006     MsiCloseHandle( hpkg );
2007     DeleteFile(msifile);
2008 }
2009
2010 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2011 {
2012     MSIHANDLE hview, hrec;
2013     BOOL found;
2014     CHAR buffer[MAX_PATH];
2015     DWORD sz;
2016     UINT r;
2017
2018     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2019     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2020     r = MsiViewExecute(hview, 0);
2021     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2022
2023     found = FALSE;
2024     while (r == ERROR_SUCCESS && !found)
2025     {
2026         r = MsiViewFetch(hview, &hrec);
2027         if (r != ERROR_SUCCESS) break;
2028
2029         sz = MAX_PATH;
2030         r = MsiRecordGetString(hrec, 1, buffer, &sz);
2031         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2032         {
2033             sz = MAX_PATH;
2034             r = MsiRecordGetString(hrec, 2, buffer, &sz);
2035             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2036                 found = TRUE;
2037         }
2038
2039         MsiCloseHandle(hrec);
2040     }
2041
2042     MsiViewClose(hview);
2043     MsiCloseHandle(hview);
2044
2045     return found;
2046 }
2047
2048 static void test_property_table(void)
2049 {
2050     const char *query;
2051     UINT r;
2052     MSIHANDLE hpkg, hdb, hrec;
2053     char buffer[MAX_PATH];
2054     DWORD sz;
2055     BOOL found;
2056
2057     hdb = create_package_db();
2058     ok( hdb, "failed to create package\n");
2059
2060     hpkg = package_from_db(hdb);
2061     ok( hpkg, "failed to create package\n");
2062
2063     MsiCloseHandle(hdb);
2064
2065     hdb = MsiGetActiveDatabase(hpkg);
2066
2067     query = "CREATE TABLE `_Property` ( "
2068         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2069     r = run_query(hdb, query);
2070     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2071
2072     MsiCloseHandle(hdb);
2073     MsiCloseHandle(hpkg);
2074     DeleteFile(msifile);
2075
2076     hdb = create_package_db();
2077     ok( hdb, "failed to create package\n");
2078
2079     query = "CREATE TABLE `_Property` ( "
2080         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2081     r = run_query(hdb, query);
2082     ok(r == ERROR_SUCCESS, "failed to create table\n");
2083
2084     query = "ALTER `_Property` ADD `foo` INTEGER";
2085     r = run_query(hdb, query);
2086     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2087
2088     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2089     r = run_query(hdb, query);
2090     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2091
2092     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2093     r = run_query(hdb, query);
2094     ok(r == ERROR_SUCCESS, "failed to add column\n");
2095
2096     hpkg = package_from_db(hdb);
2097     todo_wine
2098     {
2099         ok(!hpkg, "package should not be created\n");
2100     }
2101
2102     MsiCloseHandle(hdb);
2103     MsiCloseHandle(hpkg);
2104     DeleteFile(msifile);
2105
2106     hdb = create_package_db();
2107     ok (hdb, "failed to create package database\n");
2108
2109     r = create_property_table(hdb);
2110     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2111
2112     r = add_property_entry(hdb, "'prop', 'val'");
2113     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2114
2115     hpkg = package_from_db(hdb);
2116     ok(hpkg, "failed to create package\n");
2117
2118     MsiCloseHandle(hdb);
2119
2120     sz = MAX_PATH;
2121     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2123     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2124
2125     hdb = MsiGetActiveDatabase(hpkg);
2126
2127     found = find_prop_in_property(hdb, "prop", "val");
2128     ok(found, "prop should be in the _Property table\n");
2129
2130     r = add_property_entry(hdb, "'dantes', 'mercedes'");
2131     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2132
2133     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2134     r = do_query(hdb, query, &hrec);
2135     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2136
2137     found = find_prop_in_property(hdb, "dantes", "mercedes");
2138     ok(found == FALSE, "dantes should not be in the _Property table\n");
2139
2140     sz = MAX_PATH;
2141     lstrcpy(buffer, "aaa");
2142     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2143     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2144     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2145
2146     r = MsiSetProperty(hpkg, "dantes", "mercedes");
2147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2148
2149     found = find_prop_in_property(hdb, "dantes", "mercedes");
2150     ok(found == TRUE, "dantes should be in the _Property table\n");
2151
2152     MsiCloseHandle(hdb);
2153     MsiCloseHandle(hpkg);
2154     DeleteFile(msifile);
2155 }
2156
2157 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2158 {
2159     MSIHANDLE htab = 0;
2160     UINT res;
2161
2162     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2163     if( res == ERROR_SUCCESS )
2164     {
2165         UINT r;
2166
2167         r = MsiViewExecute( htab, hrec );
2168         if( r != ERROR_SUCCESS )
2169         {
2170             res = r;
2171             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2172         }
2173
2174         r = MsiViewClose( htab );
2175         if( r != ERROR_SUCCESS )
2176             res = r;
2177
2178         r = MsiCloseHandle( htab );
2179         if( r != ERROR_SUCCESS )
2180             res = r;
2181     }
2182     return res;
2183 }
2184
2185 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2186 {
2187     return try_query_param( hdb, szQuery, 0 );
2188 }
2189
2190 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2191 {
2192     MSIHANDLE summary;
2193     UINT r;
2194
2195     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2196     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2197
2198     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2199     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2200
2201     r = MsiSummaryInfoPersist(summary);
2202     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2203
2204     MsiCloseHandle(summary);
2205 }
2206
2207 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2208 {
2209     MSIHANDLE summary;
2210     UINT r;
2211
2212     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2214
2215     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2216     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2217
2218     r = MsiSummaryInfoPersist(summary);
2219     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2220
2221     MsiCloseHandle(summary);
2222 }
2223
2224 static void test_msipackage(void)
2225 {
2226     MSIHANDLE hdb = 0, hpack = 100;
2227     UINT r;
2228     const char *query;
2229     char name[10];
2230
2231     /* NULL szPackagePath */
2232     r = MsiOpenPackage(NULL, &hpack);
2233     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2234
2235     /* empty szPackagePath */
2236     r = MsiOpenPackage("", &hpack);
2237     todo_wine
2238     {
2239         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2240     }
2241
2242     if (r == ERROR_SUCCESS)
2243         MsiCloseHandle(hpack);
2244
2245     /* nonexistent szPackagePath */
2246     r = MsiOpenPackage("nonexistent", &hpack);
2247     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2248
2249     /* NULL hProduct */
2250     r = MsiOpenPackage(msifile, NULL);
2251     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2252
2253     name[0]='#';
2254     name[1]=0;
2255     r = MsiOpenPackage(name, &hpack);
2256     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2257
2258     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2259     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2260
2261     /* database exists, but is emtpy */
2262     sprintf(name, "#%ld", hdb);
2263     r = MsiOpenPackage(name, &hpack);
2264     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2265        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2266
2267     query = "CREATE TABLE `Property` ( "
2268             "`Property` CHAR(72), `Value` CHAR(0) "
2269             "PRIMARY KEY `Property`)";
2270     r = try_query(hdb, query);
2271     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2272
2273     query = "CREATE TABLE `InstallExecuteSequence` ("
2274             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2275             "PRIMARY KEY `Action`)";
2276     r = try_query(hdb, query);
2277     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2278
2279     /* a few key tables exist */
2280     sprintf(name, "#%ld", hdb);
2281     r = MsiOpenPackage(name, &hpack);
2282     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2283        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2284
2285     MsiCloseHandle(hdb);
2286     DeleteFile(msifile);
2287
2288     /* start with a clean database to show what constitutes a valid package */
2289     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2290     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2291
2292     sprintf(name, "#%ld", hdb);
2293
2294     /* The following summary information props must exist:
2295      *  - PID_REVNUMBER
2296      *  - PID_PAGECOUNT
2297      */
2298
2299     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2300     r = MsiOpenPackage(name, &hpack);
2301     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2302        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2303
2304     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2305     r = MsiOpenPackage(name, &hpack);
2306     ok(r == ERROR_SUCCESS,
2307        "Expected ERROR_SUCCESS, got %d\n", r);
2308
2309     MsiCloseHandle(hpack);
2310     MsiCloseHandle(hdb);
2311     DeleteFile(msifile);
2312 }
2313
2314 static void test_formatrecord2(void)
2315 {
2316     MSIHANDLE hpkg, hrec ;
2317     char buffer[0x100];
2318     DWORD sz;
2319     UINT r;
2320
2321     hpkg = package_from_db(create_package_db());
2322     ok( hpkg, "failed to create package\n");
2323
2324     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2325     ok( r == ERROR_SUCCESS, "set property failed\n");
2326
2327     hrec = MsiCreateRecord(2);
2328     ok(hrec, "create record failed\n");
2329
2330     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2331     ok( r == ERROR_SUCCESS, "format record failed\n");
2332
2333     buffer[0] = 0;
2334     sz = sizeof buffer;
2335     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2336
2337     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2338     r = MsiRecordSetString(hrec, 1, "hoo");
2339     sz = sizeof buffer;
2340     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2341     ok( sz == 3, "size wrong\n");
2342     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2343     ok( r == ERROR_SUCCESS, "format failed\n");
2344
2345     r = MsiRecordSetString(hrec, 0, "x[~]x");
2346     sz = sizeof buffer;
2347     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2348     ok( sz == 3, "size wrong\n");
2349     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2350     ok( r == ERROR_SUCCESS, "format failed\n");
2351
2352     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2353     r = MsiRecordSetString(hrec, 1, "hoo");
2354     sz = sizeof buffer;
2355     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2356     ok( sz == 3, "size wrong\n");
2357     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2358     ok( r == ERROR_SUCCESS, "format failed\n");
2359
2360     r = MsiRecordSetString(hrec, 0, "[\\[]");
2361     sz = sizeof buffer;
2362     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2363     ok( sz == 1, "size wrong\n");
2364     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2365     ok( r == ERROR_SUCCESS, "format failed\n");
2366
2367     SetEnvironmentVariable("FOO", "BAR");
2368     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2369     sz = sizeof buffer;
2370     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2371     ok( sz == 3, "size wrong\n");
2372     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2373     ok( r == ERROR_SUCCESS, "format failed\n");
2374
2375     r = MsiRecordSetString(hrec, 0, "[[1]]");
2376     r = MsiRecordSetString(hrec, 1, "%FOO");
2377     sz = sizeof buffer;
2378     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2379     ok( sz == 3, "size wrong\n");
2380     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2381     ok( r == ERROR_SUCCESS, "format failed\n");
2382
2383     MsiCloseHandle( hrec );
2384     MsiCloseHandle( hpkg );
2385     DeleteFile(msifile);
2386 }
2387
2388 static void test_states(void)
2389 {
2390     MSIHANDLE hpkg;
2391     UINT r;
2392     MSIHANDLE hdb;
2393     INSTALLSTATE state, action;
2394
2395     static const CHAR msifile2[] = "winetest2.msi";
2396     static const CHAR msifile3[] = "winetest3.msi";
2397
2398     hdb = create_package_db();
2399     ok ( hdb, "failed to create package database\n" );
2400
2401     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2402     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2403
2404     r = create_property_table( hdb );
2405     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2406
2407     r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2408     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2409
2410     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2411     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2412
2413     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2414     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2415
2416     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2417     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2418
2419     r = create_install_execute_sequence_table( hdb );
2420     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2421
2422     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2423     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2424
2425     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2426     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2427
2428     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2429     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2430
2431     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2432     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2433
2434     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2435     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2436
2437     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2438     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2439
2440     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2441     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2442
2443     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2444     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2445
2446     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2447     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2448
2449     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2450     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2451
2452     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2453     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2454
2455     r = create_media_table( hdb );
2456     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2457
2458     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2459     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2460
2461     r = create_feature_table( hdb );
2462     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2463
2464     r = create_component_table( hdb );
2465     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2466
2467     /* msidbFeatureAttributesFavorLocal */
2468     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2469     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2470
2471     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2472     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2473     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2474
2475     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2476     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2477     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2478
2479     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2480     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2481     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2482
2483     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2484     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2485     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2486
2487     /* msidbFeatureAttributesFavorSource */
2488     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2489     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2490
2491     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2492     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2493     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2494
2495     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2496     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2497     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2498
2499     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2500     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2501     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2502
2503     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2504     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2505     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2506
2507     /* msidbFeatureAttributesFavorSource */
2508     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2509     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2510
2511     /* msidbFeatureAttributesFavorLocal */
2512     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2513     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2514
2515     /* disabled */
2516     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2517     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2518
2519     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2520     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2521     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2522
2523     /* no feature parent:msidbComponentAttributesLocalOnly */
2524     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2525     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2526
2527     /* msidbFeatureAttributesFavorLocal:removed */
2528     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2529     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2530
2531     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2532     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2533     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2534
2535     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2536     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2537     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2538
2539     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2540     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2541     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2542
2543     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2544     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2545     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2546
2547     /* msidbFeatureAttributesFavorSource:removed */
2548     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2549     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2550
2551     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2552     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2553     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2554
2555     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2556     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2557     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2558
2559     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2560     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2561     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2562
2563     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2564     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2565     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2566
2567     r = create_feature_components_table( hdb );
2568     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2569
2570     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2571     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2572
2573     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2574     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2575
2576     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2577     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2578
2579     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2580     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2581
2582     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2583     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2584
2585     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2586     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2587
2588     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2589     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2590
2591     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2592     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2593
2594     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2595     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2596
2597     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2598     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2599
2600     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2601     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2602
2603     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2604     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2605
2606     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2607     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2608
2609     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2610     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2611
2612     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2613     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2614
2615     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2616     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2617
2618     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2619     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2620
2621     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2622     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2623
2624     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2625     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2626
2627     r = create_file_table( hdb );
2628     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2629
2630     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2631     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2632
2633     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2634     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2635
2636     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2637     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2638
2639     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2640     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2641
2642     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2643     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2644
2645     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2646     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2647
2648     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2649     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2650
2651     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2652     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2653
2654     /* compressed file */
2655     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2656     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2657
2658     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2659     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2660
2661     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2662     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2663
2664     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2665     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2666
2667     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2668     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2669
2670     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2671     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2672
2673     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2674     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2675
2676     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2677     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2678
2679     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2680     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2681
2682     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2683     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2684
2685     MsiDatabaseCommit(hdb);
2686
2687     /* these properties must not be in the saved msi file */
2688     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2689     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2690
2691     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2692     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2693
2694     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2695     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2696
2697     hpkg = package_from_db( hdb );
2698     ok( hpkg, "failed to create package\n");
2699
2700     MsiCloseHandle(hdb);
2701
2702     CopyFileA(msifile, msifile2, FALSE);
2703     CopyFileA(msifile, msifile3, FALSE);
2704
2705     state = 0xdeadbee;
2706     action = 0xdeadbee;
2707     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2708     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2709     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2710     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2711
2712     state = 0xdeadbee;
2713     action = 0xdeadbee;
2714     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2715     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2716     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2717     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2718
2719     state = 0xdeadbee;
2720     action = 0xdeadbee;
2721     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2722     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2723     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2724     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2725
2726     state = 0xdeadbee;
2727     action = 0xdeadbee;
2728     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2729     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2730     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2731     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2732
2733     state = 0xdeadbee;
2734     action = 0xdeadbee;
2735     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2736     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2737     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2738     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2739
2740     state = 0xdeadbee;
2741     action = 0xdeadbee;
2742     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2743     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2744     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2745     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2746
2747     state = 0xdeadbee;
2748     action = 0xdeadbee;
2749     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2750     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2751     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2752     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2753
2754     state = 0xdeadbee;
2755     action = 0xdeadbee;
2756     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2757     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2758     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2759     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2760
2761     state = 0xdeadbee;
2762     action = 0xdeadbee;
2763     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2764     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2765     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2766     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2767
2768     state = 0xdeadbee;
2769     action = 0xdeadbee;
2770     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2771     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2772     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2773     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2774
2775     state = 0xdeadbee;
2776     action = 0xdeadbee;
2777     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2778     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2779     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2780     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2781
2782     state = 0xdeadbee;
2783     action = 0xdeadbee;
2784     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2785     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2786     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2787     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2788
2789     state = 0xdeadbee;
2790     action = 0xdeadbee;
2791     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2792     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2793     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2794     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2795
2796     state = 0xdeadbee;
2797     action = 0xdeadbee;
2798     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2799     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2800     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2801     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2802
2803     state = 0xdeadbee;
2804     action = 0xdeadbee;
2805     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2806     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2807     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2808     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2809
2810     state = 0xdeadbee;
2811     action = 0xdeadbee;
2812     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2813     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2814     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2815     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2816
2817     state = 0xdeadbee;
2818     action = 0xdeadbee;
2819     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2820     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2821     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2822     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2823
2824     state = 0xdeadbee;
2825     action = 0xdeadbee;
2826     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2827     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2828     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2829     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2830
2831     state = 0xdeadbee;
2832     action = 0xdeadbee;
2833     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2834     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2835     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2836     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2837
2838     state = 0xdeadbee;
2839     action = 0xdeadbee;
2840     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2841     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2842     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2843     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2844
2845     state = 0xdeadbee;
2846     action = 0xdeadbee;
2847     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2848     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2849     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2850     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2851
2852     state = 0xdeadbee;
2853     action = 0xdeadbee;
2854     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2855     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2856     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2857     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2858
2859     state = 0xdeadbee;
2860     action = 0xdeadbee;
2861     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2862     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2863     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2864     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2865
2866     state = 0xdeadbee;
2867     action = 0xdeadbee;
2868     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2869     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2870     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2871     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2872
2873     state = 0xdeadbee;
2874     action = 0xdeadbee;
2875     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2876     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2877     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2878     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2879
2880     r = MsiDoAction( hpkg, "CostInitialize");
2881     ok( r == ERROR_SUCCESS, "cost init failed\n");
2882
2883     state = 0xdeadbee;
2884     action = 0xdeadbee;
2885     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2886     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2887     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2888     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2889
2890     state = 0xdeadbee;
2891     action = 0xdeadbee;
2892     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2893     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2894     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2895     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2896
2897     state = 0xdeadbee;
2898     action = 0xdeadbee;
2899     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2900     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2901     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2902     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2903
2904     state = 0xdeadbee;
2905     action = 0xdeadbee;
2906     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2907     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2908     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2909     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2910
2911     state = 0xdeadbee;
2912     action = 0xdeadbee;
2913     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2914     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2915     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2916     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2917
2918     state = 0xdeadbee;
2919     action = 0xdeadbee;
2920     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2921     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2922     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2923     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2924
2925     state = 0xdeadbee;
2926     action = 0xdeadbee;
2927     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2928     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2929     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2930     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2931
2932     state = 0xdeadbee;
2933     action = 0xdeadbee;
2934     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2935     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2936     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2937     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2938
2939     state = 0xdeadbee;
2940     action = 0xdeadbee;
2941     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2942     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2943     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2944     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2945
2946     state = 0xdeadbee;
2947     action = 0xdeadbee;
2948     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2949     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2950     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2951     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2952
2953     state = 0xdeadbee;
2954     action = 0xdeadbee;
2955     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2956     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2957     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2958     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2959
2960     state = 0xdeadbee;
2961     action = 0xdeadbee;
2962     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2963     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2964     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2965     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2966
2967     state = 0xdeadbee;
2968     action = 0xdeadbee;
2969     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2970     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2971     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2972     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2973
2974     state = 0xdeadbee;
2975     action = 0xdeadbee;
2976     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2977     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2978     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2979     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2980
2981     state = 0xdeadbee;
2982     action = 0xdeadbee;
2983     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2984     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2985     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2986     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2987
2988     state = 0xdeadbee;
2989     action = 0xdeadbee;
2990     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2991     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2992     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2993     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2994
2995     state = 0xdeadbee;
2996     action = 0xdeadbee;
2997     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2998     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2999     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3000     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3001
3002     state = 0xdeadbee;
3003     action = 0xdeadbee;
3004     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3005     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3006     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3007     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3008
3009     state = 0xdeadbee;
3010     action = 0xdeadbee;
3011     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3012     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3013     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3014     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3015
3016     state = 0xdeadbee;
3017     action = 0xdeadbee;
3018     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3019     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3020     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3021     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3022
3023     state = 0xdeadbee;
3024     action = 0xdeadbee;
3025     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3026     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3027     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3028     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3029
3030     state = 0xdeadbee;
3031     action = 0xdeadbee;
3032     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3033     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3034     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3035     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3036
3037     state = 0xdeadbee;
3038     action = 0xdeadbee;
3039     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3040     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3041     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3042     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3043
3044     state = 0xdeadbee;
3045     action = 0xdeadbee;
3046     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3047     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3048     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3049     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3050
3051     state = 0xdeadbee;
3052     action = 0xdeadbee;
3053     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3054     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3055     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3056     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3057
3058     r = MsiDoAction( hpkg, "FileCost");
3059     ok( r == ERROR_SUCCESS, "file cost failed\n");
3060
3061     state = 0xdeadbee;
3062     action = 0xdeadbee;
3063     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3064     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3065     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3066     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3067
3068     state = 0xdeadbee;
3069     action = 0xdeadbee;
3070     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3071     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3072     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3073     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3074
3075     state = 0xdeadbee;
3076     action = 0xdeadbee;
3077     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3078     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3079     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3080     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3081
3082     state = 0xdeadbee;
3083     action = 0xdeadbee;
3084     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3085     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3086     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3087     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3088
3089     state = 0xdeadbee;
3090     action = 0xdeadbee;
3091     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3092     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3093     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3094     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3095
3096     state = 0xdeadbee;
3097     action = 0xdeadbee;
3098     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3099     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3100     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3101     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3102
3103     state = 0xdeadbee;
3104     action = 0xdeadbee;
3105     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3106     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3107     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3108     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3109
3110     state = 0xdeadbee;
3111     action = 0xdeadbee;
3112     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3113     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3114     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3115     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3116
3117     state = 0xdeadbee;
3118     action = 0xdeadbee;
3119     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3120     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3121     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3122     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3123
3124     state = 0xdeadbee;
3125     action = 0xdeadbee;
3126     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3127     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3128     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3129     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3130
3131     state = 0xdeadbee;
3132     action = 0xdeadbee;
3133     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3134     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3135     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3136     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3137
3138     state = 0xdeadbee;
3139     action = 0xdeadbee;
3140     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3141     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3142     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3143     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3144
3145     state = 0xdeadbee;
3146     action = 0xdeadbee;
3147     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3148     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3149     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3150     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3151
3152     state = 0xdeadbee;
3153     action = 0xdeadbee;
3154     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3156     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3157     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3158
3159     state = 0xdeadbee;
3160     action = 0xdeadbee;
3161     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3162     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3163     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3164     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3165
3166     state = 0xdeadbee;
3167     action = 0xdeadbee;
3168     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3169     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3170     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3171     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3172
3173     state = 0xdeadbee;
3174     action = 0xdeadbee;
3175     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3176     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3177     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3178     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3179
3180     state = 0xdeadbee;
3181     action = 0xdeadbee;
3182     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3184     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3185     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3186
3187     state = 0xdeadbee;
3188     action = 0xdeadbee;
3189     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3191     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3192     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3193
3194     state = 0xdeadbee;
3195     action = 0xdeadbee;
3196     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3197     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3198     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3199     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3200
3201     state = 0xdeadbee;
3202     action = 0xdeadbee;
3203     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3204     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3205     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3206     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3207
3208     state = 0xdeadbee;
3209     action = 0xdeadbee;
3210     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3211     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3212     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3213     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3214
3215     state = 0xdeadbee;
3216     action = 0xdeadbee;
3217     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3218     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3219     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3220     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3221
3222     state = 0xdeadbee;
3223     action = 0xdeadbee;
3224     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3225     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3226     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3227     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3228
3229     state = 0xdeadbee;
3230     action = 0xdeadbee;
3231     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3232     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3233     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3234     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3235
3236     r = MsiDoAction( hpkg, "CostFinalize");
3237     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3238
3239     state = 0xdeadbee;
3240     action = 0xdeadbee;
3241     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3242     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3243     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3244     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3245
3246     state = 0xdeadbee;
3247     action = 0xdeadbee;
3248     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3249     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3250     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3251     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3252
3253     state = 0xdeadbee;
3254     action = 0xdeadbee;
3255     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3256     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3257     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3258     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3259
3260     state = 0xdeadbee;
3261     action = 0xdeadbee;
3262     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3263     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3264     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3265     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3266
3267     state = 0xdeadbee;
3268     action = 0xdeadbee;
3269     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3270     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3271     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3272     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3273
3274     state = 0xdeadbee;
3275     action = 0xdeadbee;
3276     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3277     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3278     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3279     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3280
3281     state = 0xdeadbee;
3282     action = 0xdeadbee;
3283     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3284     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3285     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3286     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3287
3288     state = 0xdeadbee;
3289     action = 0xdeadbee;
3290     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3291     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3292     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3293     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3294
3295     state = 0xdeadbee;
3296     action = 0xdeadbee;
3297     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3298     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3299     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3300     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3301
3302     state = 0xdeadbee;
3303     action = 0xdeadbee;
3304     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3305     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3306     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3307     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3308
3309     state = 0xdeadbee;
3310     action = 0xdeadbee;
3311     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3312     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3313     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3314     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3315
3316     state = 0xdeadbee;
3317     action = 0xdeadbee;
3318     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3319     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3320     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3321     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3322
3323     state = 0xdeadbee;
3324     action = 0xdeadbee;
3325     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3326     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3327     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3328     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3329
3330     state = 0xdeadbee;
3331     action = 0xdeadbee;
3332     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3333     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3334     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3335     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3336
3337     state = 0xdeadbee;
3338     action = 0xdeadbee;
3339     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3340     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3341     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3342     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3343
3344     state = 0xdeadbee;
3345     action = 0xdeadbee;
3346     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3347     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3348     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3349     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3350
3351     state = 0xdeadbee;
3352     action = 0xdeadbee;
3353     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3354     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3355     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3356     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3357
3358     state = 0xdeadbee;
3359     action = 0xdeadbee;
3360     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3361     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3362     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3363     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3364
3365     state = 0xdeadbee;
3366     action = 0xdeadbee;
3367     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3368     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3369     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3370     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3371
3372     state = 0xdeadbee;
3373     action = 0xdeadbee;
3374     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3375     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3376     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3377     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3378
3379     state = 0xdeadbee;
3380     action = 0xdeadbee;
3381     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3382     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3383     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3384     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3385
3386     state = 0xdeadbee;
3387     action = 0xdeadbee;
3388     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3389     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3390     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3391     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3392
3393     state = 0xdeadbee;
3394     action = 0xdeadbee;
3395     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3396     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3397     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3398     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3399
3400     state = 0xdeadbee;
3401     action = 0xdeadbee;
3402     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3403     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3404     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3405     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3406
3407     state = 0xdeadbee;
3408     action = 0xdeadbee;
3409     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3410     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3411     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3412     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3413
3414     MsiCloseHandle( hpkg );
3415
3416     /* publish the features and components */
3417     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven");
3418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3419
3420     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3421     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3422
3423     /* these properties must not be in the saved msi file */
3424     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3425     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3426
3427     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3428     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3429
3430     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3431     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3432
3433     hpkg = package_from_db( hdb );
3434     ok( hpkg, "failed to create package\n");
3435
3436     MsiCloseHandle(hdb);
3437
3438     state = 0xdeadbee;
3439     action = 0xdeadbee;
3440     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3441     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3442     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3443     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3444
3445     state = 0xdeadbee;
3446     action = 0xdeadbee;
3447     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3448     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3449     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3450     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3451
3452     state = 0xdeadbee;
3453     action = 0xdeadbee;
3454     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3455     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3456     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3457     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3458
3459     state = 0xdeadbee;
3460     action = 0xdeadbee;
3461     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3462     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3463     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3464     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3465
3466     state = 0xdeadbee;
3467     action = 0xdeadbee;
3468     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3469     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3470     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3471     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3472
3473     state = 0xdeadbee;
3474     action = 0xdeadbee;
3475     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3476     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3477     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3478     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3479
3480     state = 0xdeadbee;
3481     action = 0xdeadbee;
3482     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3483     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3484     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3485     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3486
3487     state = 0xdeadbee;
3488     action = 0xdeadbee;
3489     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3490     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3491     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3492     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3493
3494     state = 0xdeadbee;
3495     action = 0xdeadbee;
3496     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3497     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3498     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3499     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3500
3501     state = 0xdeadbee;
3502     action = 0xdeadbee;
3503     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3504     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3505     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3506     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3507
3508     state = 0xdeadbee;
3509     action = 0xdeadbee;
3510     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3511     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3512     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3513     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3514
3515     state = 0xdeadbee;
3516     action = 0xdeadbee;
3517     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3518     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3519     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3520     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3521
3522     state = 0xdeadbee;
3523     action = 0xdeadbee;
3524     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3525     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3526     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3527     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3528
3529     state = 0xdeadbee;
3530     action = 0xdeadbee;
3531     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3532     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3533     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3534     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3535
3536     state = 0xdeadbee;
3537     action = 0xdeadbee;
3538     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3539     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3540     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3541     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3542
3543     state = 0xdeadbee;
3544     action = 0xdeadbee;
3545     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3546     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3547     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3548     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3549
3550     state = 0xdeadbee;
3551     action = 0xdeadbee;
3552     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3553     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3554     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3555     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3556
3557     state = 0xdeadbee;
3558     action = 0xdeadbee;
3559     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3560     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3561     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3562     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3563
3564     state = 0xdeadbee;
3565     action = 0xdeadbee;
3566     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3567     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3568     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3569     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3570
3571     state = 0xdeadbee;
3572     action = 0xdeadbee;
3573     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3574     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3575     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3576     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3577
3578     state = 0xdeadbee;
3579     action = 0xdeadbee;
3580     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3581     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3582     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3583     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3584
3585     state = 0xdeadbee;
3586     action = 0xdeadbee;
3587     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3588     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3589     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3590     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3591
3592     state = 0xdeadbee;
3593     action = 0xdeadbee;
3594     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3595     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3596     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3597     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3598
3599     state = 0xdeadbee;
3600     action = 0xdeadbee;
3601     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3602     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3603     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3604     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3605
3606     state = 0xdeadbee;
3607     action = 0xdeadbee;
3608     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3609     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3610     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3611     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3612
3613     r = MsiDoAction( hpkg, "CostInitialize");
3614     ok( r == ERROR_SUCCESS, "cost init failed\n");
3615
3616     state = 0xdeadbee;
3617     action = 0xdeadbee;
3618     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3619     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3620     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3621     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3622
3623     state = 0xdeadbee;
3624     action = 0xdeadbee;
3625     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3626     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3627     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3628     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3629
3630     state = 0xdeadbee;
3631     action = 0xdeadbee;
3632     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3633     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3634     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3635     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3636
3637     state = 0xdeadbee;
3638     action = 0xdeadbee;
3639     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3640     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3641     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3642     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3643
3644     state = 0xdeadbee;
3645     action = 0xdeadbee;
3646     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3647     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3648     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3649     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3650
3651     state = 0xdeadbee;
3652     action = 0xdeadbee;
3653     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3654     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3655     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3656     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3657
3658     state = 0xdeadbee;
3659     action = 0xdeadbee;
3660     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3661     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3662     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3663     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3664
3665     state = 0xdeadbee;
3666     action = 0xdeadbee;
3667     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3668     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3669     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3670     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3671
3672     state = 0xdeadbee;
3673     action = 0xdeadbee;
3674     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3675     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3676     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3677     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3678
3679     state = 0xdeadbee;
3680     action = 0xdeadbee;
3681     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3682     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3683     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3684     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3685
3686     state = 0xdeadbee;
3687     action = 0xdeadbee;
3688     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3689     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3690     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3691     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3692
3693     state = 0xdeadbee;
3694     action = 0xdeadbee;
3695     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3696     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3697     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3698     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3699
3700     state = 0xdeadbee;
3701     action = 0xdeadbee;
3702     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3703     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3704     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3705     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3706
3707     state = 0xdeadbee;
3708     action = 0xdeadbee;
3709     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3710     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3711     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3712     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3713
3714     state = 0xdeadbee;
3715     action = 0xdeadbee;
3716     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3717     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3718     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3719     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3720
3721     state = 0xdeadbee;
3722     action = 0xdeadbee;
3723     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3724     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3725     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3726     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3727
3728     state = 0xdeadbee;
3729     action = 0xdeadbee;
3730     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3731     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3732     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3733     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3734
3735     state = 0xdeadbee;
3736     action = 0xdeadbee;
3737     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3738     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3739     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3740     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3741
3742     state = 0xdeadbee;
3743     action = 0xdeadbee;
3744     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3745     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3746     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3747     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3748
3749     state = 0xdeadbee;
3750     action = 0xdeadbee;
3751     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3752     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3753     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3754     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3755
3756     state = 0xdeadbee;
3757     action = 0xdeadbee;
3758     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3759     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3760     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3761     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3762
3763     state = 0xdeadbee;
3764     action = 0xdeadbee;
3765     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3766     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3767     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3768     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3769
3770     state = 0xdeadbee;
3771     action = 0xdeadbee;
3772     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3773     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3774     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3775     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3776
3777     state = 0xdeadbee;
3778     action = 0xdeadbee;
3779     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3780     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3781     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3782     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3783
3784     state = 0xdeadbee;
3785     action = 0xdeadbee;
3786     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3787     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3788     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3789     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3790
3791     r = MsiDoAction( hpkg, "FileCost");
3792     ok( r == ERROR_SUCCESS, "file cost failed\n");
3793
3794     state = 0xdeadbee;
3795     action = 0xdeadbee;
3796     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3797     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3798     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3799     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3800
3801     state = 0xdeadbee;
3802     action = 0xdeadbee;
3803     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3804     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3805     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3806     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3807
3808     state = 0xdeadbee;
3809     action = 0xdeadbee;
3810     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3811     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3812     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3813     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3814
3815     state = 0xdeadbee;
3816     action = 0xdeadbee;
3817     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3818     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3819     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3820     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3821
3822     state = 0xdeadbee;
3823     action = 0xdeadbee;
3824     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3825     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3826     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3827     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3828
3829     state = 0xdeadbee;
3830     action = 0xdeadbee;
3831     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3832     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3833     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3834     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3835
3836     state = 0xdeadbee;
3837     action = 0xdeadbee;
3838     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3839     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3840     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3841     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3842
3843     state = 0xdeadbee;
3844     action = 0xdeadbee;
3845     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3846     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3847     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3848     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3849
3850     state = 0xdeadbee;
3851     action = 0xdeadbee;
3852     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3853     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3854     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3855     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3856
3857     state = 0xdeadbee;
3858     action = 0xdeadbee;
3859     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3860     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3861     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3862     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3863
3864     state = 0xdeadbee;
3865     action = 0xdeadbee;
3866     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3867     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3868     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3869     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3870
3871     state = 0xdeadbee;
3872     action = 0xdeadbee;
3873     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3874     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3875     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3876     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3877
3878     state = 0xdeadbee;
3879     action = 0xdeadbee;
3880     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3881     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3882     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3883     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3884
3885     state = 0xdeadbee;
3886     action = 0xdeadbee;
3887     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3888     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3889     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3890     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3891
3892     state = 0xdeadbee;
3893     action = 0xdeadbee;
3894     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3895     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3896     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3897     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3898
3899     state = 0xdeadbee;
3900     action = 0xdeadbee;
3901     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3902     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3903     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3904     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3905
3906     state = 0xdeadbee;
3907     action = 0xdeadbee;
3908     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3909     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3910     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3911     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3912
3913     state = 0xdeadbee;
3914     action = 0xdeadbee;
3915     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3916     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3917     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3918     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3919
3920     state = 0xdeadbee;
3921     action = 0xdeadbee;
3922     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3923     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3924     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3925     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3926
3927     state = 0xdeadbee;
3928     action = 0xdeadbee;
3929     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3930     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3931     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3932     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3933
3934     state = 0xdeadbee;
3935     action = 0xdeadbee;
3936     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3937     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3938     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3939     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3940
3941     state = 0xdeadbee;
3942     action = 0xdeadbee;
3943     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3944     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3945     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3946     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3947
3948     state = 0xdeadbee;
3949     action = 0xdeadbee;
3950     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3951     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3952     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3953     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3954
3955     state = 0xdeadbee;
3956     action = 0xdeadbee;
3957     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3958     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3959     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3960     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3961
3962     state = 0xdeadbee;
3963     action = 0xdeadbee;
3964     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3965     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3966     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3967     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3968
3969     r = MsiDoAction( hpkg, "CostFinalize");
3970     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3971
3972     state = 0xdeadbee;
3973     action = 0xdeadbee;
3974     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3975     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3976     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3977     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3978
3979     state = 0xdeadbee;
3980     action = 0xdeadbee;
3981     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3982     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3983     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3984     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3985
3986     state = 0xdeadbee;
3987     action = 0xdeadbee;
3988     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3989     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3990     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3991     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3992
3993     state = 0xdeadbee;
3994     action = 0xdeadbee;
3995     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3996     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3997     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3998     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3999
4000     state = 0xdeadbee;
4001     action = 0xdeadbee;
4002     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4003     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4004     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4005     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4006
4007     state = 0xdeadbee;
4008     action = 0xdeadbee;
4009     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4010     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4011     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4012     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4013
4014     state = 0xdeadbee;
4015     action = 0xdeadbee;
4016     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4017     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4018     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4019     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4020
4021     state = 0xdeadbee;
4022     action = 0xdeadbee;
4023     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4024     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4025     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4026     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4027
4028     state = 0xdeadbee;
4029     action = 0xdeadbee;
4030     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4031     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4032     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4033     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4034
4035     state = 0xdeadbee;
4036     action = 0xdeadbee;
4037     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4038     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4039     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4040     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4041
4042     state = 0xdeadbee;
4043     action = 0xdeadbee;
4044     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4045     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4046     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4047     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4048
4049     state = 0xdeadbee;
4050     action = 0xdeadbee;
4051     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4052     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4053     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4054     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4055
4056     state = 0xdeadbee;
4057     action = 0xdeadbee;
4058     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4059     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4060     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4061     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4062
4063     state = 0xdeadbee;
4064     action = 0xdeadbee;
4065     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4066     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4067     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4068     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4069
4070     state = 0xdeadbee;
4071     action = 0xdeadbee;
4072     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4073     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4074     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4075     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4076
4077     state = 0xdeadbee;
4078     action = 0xdeadbee;
4079     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4080     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4081     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4082     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4083
4084     state = 0xdeadbee;
4085     action = 0xdeadbee;
4086     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4087     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4088     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4089     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4090
4091     state = 0xdeadbee;
4092     action = 0xdeadbee;
4093     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4094     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4095     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4096     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4097
4098     state = 0xdeadbee;
4099     action = 0xdeadbee;
4100     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4101     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4102     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4103     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4104
4105     state = 0xdeadbee;
4106     action = 0xdeadbee;
4107     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4108     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4109     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4110     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4111
4112     state = 0xdeadbee;
4113     action = 0xdeadbee;
4114     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4115     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4116     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4117     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4118
4119     state = 0xdeadbee;
4120     action = 0xdeadbee;
4121     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4122     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4123     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4124     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4125
4126     state = 0xdeadbee;
4127     action = 0xdeadbee;
4128     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4129     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4130     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4131     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4132
4133     state = 0xdeadbee;
4134     action = 0xdeadbee;
4135     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4136     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4137     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4138     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4139
4140     state = 0xdeadbee;
4141     action = 0xdeadbee;
4142     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4143     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4144     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4145     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4146
4147     MsiCloseHandle(hpkg);
4148
4149     /* uninstall the product */
4150     r = MsiInstallProduct(msifile, "REMOVE=ALL");
4151     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4152
4153     /* all features installed locally */
4154     r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
4155     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4156
4157     r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
4158     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4159
4160     /* these properties must not be in the saved msi file */
4161     r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven'");
4162     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4163
4164     hpkg = package_from_db( hdb );
4165     ok( hpkg, "failed to create package\n");
4166
4167     state = 0xdeadbee;
4168     action = 0xdeadbee;
4169     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4170     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4171     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4172     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4173
4174     state = 0xdeadbee;
4175     action = 0xdeadbee;
4176     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4177     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4178     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4179     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4180
4181     state = 0xdeadbee;
4182     action = 0xdeadbee;
4183     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4184     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4185     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4186     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4187
4188     state = 0xdeadbee;
4189     action = 0xdeadbee;
4190     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4191     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4192     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4193     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4194
4195     state = 0xdeadbee;
4196     action = 0xdeadbee;
4197     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4198     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4199     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4200     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4201
4202     state = 0xdeadbee;
4203     action = 0xdeadbee;
4204     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4205     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4206     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4207     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4208
4209     state = 0xdeadbee;
4210     action = 0xdeadbee;
4211     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4212     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4213     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4214     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4215
4216     state = 0xdeadbee;
4217     action = 0xdeadbee;
4218     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4219     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4220     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4221     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4222
4223     state = 0xdeadbee;
4224     action = 0xdeadbee;
4225     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4226     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4227     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4228     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4229
4230     state = 0xdeadbee;
4231     action = 0xdeadbee;
4232     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4233     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4234     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4235     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4236
4237     state = 0xdeadbee;
4238     action = 0xdeadbee;
4239     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4240     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4241     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4242     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4243
4244     state = 0xdeadbee;
4245     action = 0xdeadbee;
4246     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4247     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4248     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4249     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4250
4251     state = 0xdeadbee;
4252     action = 0xdeadbee;
4253     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4254     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4255     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4256     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4257
4258     state = 0xdeadbee;
4259     action = 0xdeadbee;
4260     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4261     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4262     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4263     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4264
4265     state = 0xdeadbee;
4266     action = 0xdeadbee;
4267     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4268     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4269     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4270     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4271
4272     state = 0xdeadbee;
4273     action = 0xdeadbee;
4274     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4275     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4276     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4277     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4278
4279     state = 0xdeadbee;
4280     action = 0xdeadbee;
4281     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4282     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4283     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4284     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4285
4286     state = 0xdeadbee;
4287     action = 0xdeadbee;
4288     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4289     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4290     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4291     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4292
4293     state = 0xdeadbee;
4294     action = 0xdeadbee;
4295     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4296     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4297     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4298     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4299
4300     state = 0xdeadbee;
4301     action = 0xdeadbee;
4302     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4303     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4304     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4305     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4306
4307     state = 0xdeadbee;
4308     action = 0xdeadbee;
4309     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4310     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4311     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4312     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4313
4314     state = 0xdeadbee;
4315     action = 0xdeadbee;
4316     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4317     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4318     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4319     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4320
4321     state = 0xdeadbee;
4322     action = 0xdeadbee;
4323     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4324     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4325     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4326     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4327
4328     state = 0xdeadbee;
4329     action = 0xdeadbee;
4330     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4331     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4332     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4333     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4334
4335     state = 0xdeadbee;
4336     action = 0xdeadbee;
4337     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4338     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4339     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4340     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4341
4342     r = MsiDoAction( hpkg, "CostInitialize");
4343     ok( r == ERROR_SUCCESS, "cost init failed\n");
4344
4345     state = 0xdeadbee;
4346     action = 0xdeadbee;
4347     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4348     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4349     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4350     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4351
4352     state = 0xdeadbee;
4353     action = 0xdeadbee;
4354     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4355     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4356     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4357     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4358
4359     state = 0xdeadbee;
4360     action = 0xdeadbee;
4361     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4362     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4363     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4364     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4365
4366     state = 0xdeadbee;
4367     action = 0xdeadbee;
4368     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4369     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4370     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4371     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4372
4373     state = 0xdeadbee;
4374     action = 0xdeadbee;
4375     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4376     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4377     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4378     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4379
4380     state = 0xdeadbee;
4381     action = 0xdeadbee;
4382     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4383     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4384     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4385     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4386
4387     state = 0xdeadbee;
4388     action = 0xdeadbee;
4389     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4390     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4391     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4392     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4393
4394     state = 0xdeadbee;
4395     action = 0xdeadbee;
4396     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4397     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4398     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4399     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4400
4401     state = 0xdeadbee;
4402     action = 0xdeadbee;
4403     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4406     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4407
4408     state = 0xdeadbee;
4409     action = 0xdeadbee;
4410     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4411     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4412     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4413     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4414
4415     state = 0xdeadbee;
4416     action = 0xdeadbee;
4417     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4418     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4419     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4420     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4421
4422     state = 0xdeadbee;
4423     action = 0xdeadbee;
4424     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4425     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4426     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4427     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4428
4429     state = 0xdeadbee;
4430     action = 0xdeadbee;
4431     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4432     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4433     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4434     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4435
4436     state = 0xdeadbee;
4437     action = 0xdeadbee;
4438     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4439     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4440     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4441     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4442
4443     state = 0xdeadbee;
4444     action = 0xdeadbee;
4445     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4446     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4447     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4448     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4449
4450     state = 0xdeadbee;
4451     action = 0xdeadbee;
4452     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4453     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4454     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4455     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4456
4457     state = 0xdeadbee;
4458     action = 0xdeadbee;
4459     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4460     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4461     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4462     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4463
4464     state = 0xdeadbee;
4465     action = 0xdeadbee;
4466     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4468     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4469     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4470
4471     state = 0xdeadbee;
4472     action = 0xdeadbee;
4473     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4475     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4476     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4477
4478     state = 0xdeadbee;
4479     action = 0xdeadbee;
4480     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4482     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4483     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4484
4485     state = 0xdeadbee;
4486     action = 0xdeadbee;
4487     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4489     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4490     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4491
4492     state = 0xdeadbee;
4493     action = 0xdeadbee;
4494     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4495     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4496     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4497     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4498
4499     state = 0xdeadbee;
4500     action = 0xdeadbee;
4501     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4502     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4503     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4504     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4505
4506     state = 0xdeadbee;
4507     action = 0xdeadbee;
4508     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4509     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4510     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4511     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4512
4513     state = 0xdeadbee;
4514     action = 0xdeadbee;
4515     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4516     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4517     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4518     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4519
4520     r = MsiDoAction( hpkg, "FileCost");
4521     ok( r == ERROR_SUCCESS, "file cost failed\n");
4522
4523     state = 0xdeadbee;
4524     action = 0xdeadbee;
4525     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4526     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4527     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4528     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4529
4530     state = 0xdeadbee;
4531     action = 0xdeadbee;
4532     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4533     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4534     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4535     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4536
4537     state = 0xdeadbee;
4538     action = 0xdeadbee;
4539     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4541     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4542     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4543
4544     state = 0xdeadbee;
4545     action = 0xdeadbee;
4546     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4548     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4549     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4550
4551     state = 0xdeadbee;
4552     action = 0xdeadbee;
4553     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4555     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4556     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4557
4558     state = 0xdeadbee;
4559     action = 0xdeadbee;
4560     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4562     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4563     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4564
4565     state = 0xdeadbee;
4566     action = 0xdeadbee;
4567     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4569     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4570     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4571
4572     state = 0xdeadbee;
4573     action = 0xdeadbee;
4574     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4576     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4577     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4578
4579     state = 0xdeadbee;
4580     action = 0xdeadbee;
4581     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4583     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4584     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4585
4586     state = 0xdeadbee;
4587     action = 0xdeadbee;
4588     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4590     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4591     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4592
4593     state = 0xdeadbee;
4594     action = 0xdeadbee;
4595     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4597     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4598     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4599
4600     state = 0xdeadbee;
4601     action = 0xdeadbee;
4602     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4604     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4605     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4606
4607     state = 0xdeadbee;
4608     action = 0xdeadbee;
4609     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4611     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4612     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4613
4614     state = 0xdeadbee;
4615     action = 0xdeadbee;
4616     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4618     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4619     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4620
4621     state = 0xdeadbee;
4622     action = 0xdeadbee;
4623     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4625     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4626     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4627
4628     state = 0xdeadbee;
4629     action = 0xdeadbee;
4630     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4632     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4633     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4634
4635     state = 0xdeadbee;
4636     action = 0xdeadbee;
4637     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4639     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4640     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4641
4642     state = 0xdeadbee;
4643     action = 0xdeadbee;
4644     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4645     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4646     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4647     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4648
4649     state = 0xdeadbee;
4650     action = 0xdeadbee;
4651     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4653     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4654     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4655
4656     state = 0xdeadbee;
4657     action = 0xdeadbee;
4658     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4660     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4661     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4662
4663     state = 0xdeadbee;
4664     action = 0xdeadbee;
4665     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4667     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4668     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4669
4670     state = 0xdeadbee;
4671     action = 0xdeadbee;
4672     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4674     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4675     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4676
4677     state = 0xdeadbee;
4678     action = 0xdeadbee;
4679     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4681     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4682     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4683
4684     state = 0xdeadbee;
4685     action = 0xdeadbee;
4686     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4688     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4689     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4690
4691     state = 0xdeadbee;
4692     action = 0xdeadbee;
4693     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4695     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4696     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4697
4698     r = MsiDoAction( hpkg, "CostFinalize");
4699     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
4700
4701     state = 0xdeadbee;
4702     action = 0xdeadbee;
4703     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4705     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4706     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4707
4708     state = 0xdeadbee;
4709     action = 0xdeadbee;
4710     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4712     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4713     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4714
4715     state = 0xdeadbee;
4716     action = 0xdeadbee;
4717     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4718     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4719     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4720     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4721
4722     state = 0xdeadbee;
4723     action = 0xdeadbee;
4724     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4725     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4726     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4727     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4728
4729     state = 0xdeadbee;
4730     action = 0xdeadbee;
4731     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4732     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4733     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4734     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4735
4736     state = 0xdeadbee;
4737     action = 0xdeadbee;
4738     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4739     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4740     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4741     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4742
4743     state = 0xdeadbee;
4744     action = 0xdeadbee;
4745     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4746     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4747     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4748     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4749
4750     state = 0xdeadbee;
4751     action = 0xdeadbee;
4752     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4753     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4754     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4755     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4756
4757     state = 0xdeadbee;
4758     action = 0xdeadbee;
4759     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4760     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4761     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4762     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4763
4764     state = 0xdeadbee;
4765     action = 0xdeadbee;
4766     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4767     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4768     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4769     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4770
4771     state = 0xdeadbee;
4772     action = 0xdeadbee;
4773     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4774     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4775     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4776     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4777
4778     state = 0xdeadbee;
4779     action = 0xdeadbee;
4780     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4781     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4782     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4783     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4784
4785     state = 0xdeadbee;
4786     action = 0xdeadbee;
4787     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4788     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4789     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4790     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4791
4792     state = 0xdeadbee;
4793     action = 0xdeadbee;
4794     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4795     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4796     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4797     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4798
4799     state = 0xdeadbee;
4800     action = 0xdeadbee;
4801     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4802     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4803     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4804     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4805
4806     state = 0xdeadbee;
4807     action = 0xdeadbee;
4808     r = MsiGetComponentState(hpkg, "eta", &state, &action);
4809     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4810     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4811     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4812
4813     state = 0xdeadbee;
4814     action = 0xdeadbee;
4815     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
4816     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4817     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4818     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4819
4820     state = 0xdeadbee;
4821     action = 0xdeadbee;
4822     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
4823     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4824     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4825     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4826
4827     state = 0xdeadbee;
4828     action = 0xdeadbee;
4829     r = MsiGetComponentState(hpkg, "mu", &state, &action);
4830     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4831     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4832     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4833
4834     state = 0xdeadbee;
4835     action = 0xdeadbee;
4836     r = MsiGetComponentState(hpkg, "nu", &state, &action);
4837     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4838     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4839     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4840
4841     state = 0xdeadbee;
4842     action = 0xdeadbee;
4843     r = MsiGetComponentState(hpkg, "xi", &state, &action);
4844     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4845     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4846     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4847
4848     state = 0xdeadbee;
4849     action = 0xdeadbee;
4850     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
4851     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4852     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4853     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4854
4855     state = 0xdeadbee;
4856     action = 0xdeadbee;
4857     r = MsiGetComponentState(hpkg, "pi", &state, &action);
4858     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4859     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
4860     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4861
4862     state = 0xdeadbee;
4863     action = 0xdeadbee;
4864     r = MsiGetComponentState(hpkg, "rho", &state, &action);
4865     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4866     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4867     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4868
4869     state = 0xdeadbee;
4870     action = 0xdeadbee;
4871     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
4872     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4873     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4874     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
4875
4876     MsiCloseHandle(hpkg);
4877
4878     /* uninstall the product */
4879     r = MsiInstallProduct(msifile2, "REMOVE=ALL");
4880     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4881
4882     /* all features installed from source */
4883     r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
4884     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4885
4886     r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
4887     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
4888
4889     /* this property must not be in the saved msi file */
4890     r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven'");
4891     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
4892
4893     hpkg = package_from_db( hdb );
4894     ok( hpkg, "failed to create package\n");
4895
4896     state = 0xdeadbee;
4897     action = 0xdeadbee;
4898     r = MsiGetFeatureState(hpkg, "one", &state, &action);
4899     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4900     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4901     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4902
4903     state = 0xdeadbee;
4904     action = 0xdeadbee;
4905     r = MsiGetFeatureState(hpkg, "two", &state, &action);
4906     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4907     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4908     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4909
4910     state = 0xdeadbee;
4911     action = 0xdeadbee;
4912     r = MsiGetFeatureState(hpkg, "three", &state, &action);
4913     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4914     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4915     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4916
4917     state = 0xdeadbee;
4918     action = 0xdeadbee;
4919     r = MsiGetFeatureState(hpkg, "four", &state, &action);
4920     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4921     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4922     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4923
4924     state = 0xdeadbee;
4925     action = 0xdeadbee;
4926     r = MsiGetFeatureState(hpkg, "five", &state, &action);
4927     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4928     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4929     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4930
4931     state = 0xdeadbee;
4932     action = 0xdeadbee;
4933     r = MsiGetFeatureState(hpkg, "six", &state, &action);
4934     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4935     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4936     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4937
4938     state = 0xdeadbee;
4939     action = 0xdeadbee;
4940     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
4941     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
4942     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4943     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4944
4945     state = 0xdeadbee;
4946     action = 0xdeadbee;
4947     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
4948     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4949     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4950     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4951
4952     state = 0xdeadbee;
4953     action = 0xdeadbee;
4954     r = MsiGetComponentState(hpkg, "beta", &state, &action);
4955     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4956     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4957     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4958
4959     state = 0xdeadbee;
4960     action = 0xdeadbee;
4961     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
4962     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4963     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4964     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4965
4966     state = 0xdeadbee;
4967     action = 0xdeadbee;
4968     r = MsiGetComponentState(hpkg, "theta", &state, &action);
4969     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4970     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4971     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4972
4973     state = 0xdeadbee;
4974     action = 0xdeadbee;
4975     r = MsiGetComponentState(hpkg, "delta", &state, &action);
4976     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4977     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4978     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4979
4980     state = 0xdeadbee;
4981     action = 0xdeadbee;
4982     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
4983     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4984     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4985     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4986
4987     state = 0xdeadbee;
4988     action = 0xdeadbee;
4989     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
4990     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4991     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4992     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
4993
4994     state = 0xdeadbee;
4995     action = 0xdeadbee;
4996     r = MsiGetComponentState(hpkg, "iota", &state, &action);
4997     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
4998     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
4999     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5000
5001     state = 0xdeadbee;
5002     action = 0xdeadbee;
5003     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5004     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5005     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5006     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5007
5008     state = 0xdeadbee;
5009     action = 0xdeadbee;
5010     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5011     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5012     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5013     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5014
5015     state = 0xdeadbee;
5016     action = 0xdeadbee;
5017     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5018     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5019     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5020     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5021
5022     state = 0xdeadbee;
5023     action = 0xdeadbee;
5024     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5025     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5026     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5027     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5028
5029     state = 0xdeadbee;
5030     action = 0xdeadbee;
5031     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5032     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5033     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5034     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5035
5036     state = 0xdeadbee;
5037     action = 0xdeadbee;
5038     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5039     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5040     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5041     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5042
5043     state = 0xdeadbee;
5044     action = 0xdeadbee;
5045     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5046     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5047     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5048     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5049
5050     state = 0xdeadbee;
5051     action = 0xdeadbee;
5052     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5053     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5054     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5055     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5056
5057     state = 0xdeadbee;
5058     action = 0xdeadbee;
5059     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5060     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5061     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5062     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5063
5064     state = 0xdeadbee;
5065     action = 0xdeadbee;
5066     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5067     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
5068     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
5069     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
5070
5071     r = MsiDoAction( hpkg, "CostInitialize");
5072     ok( r == ERROR_SUCCESS, "cost init failed\n");
5073
5074     state = 0xdeadbee;
5075     action = 0xdeadbee;
5076     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5077     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5078     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5079     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5080
5081     state = 0xdeadbee;
5082     action = 0xdeadbee;
5083     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5084     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5085     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5086     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5087
5088     state = 0xdeadbee;
5089     action = 0xdeadbee;
5090     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5091     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5092     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5093     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5094
5095     state = 0xdeadbee;
5096     action = 0xdeadbee;
5097     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5098     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5099     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5100     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5101
5102     state = 0xdeadbee;
5103     action = 0xdeadbee;
5104     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5105     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5106     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5107     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5108
5109     state = 0xdeadbee;
5110     action = 0xdeadbee;
5111     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5112     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5113     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5114     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5115
5116     state = 0xdeadbee;
5117     action = 0xdeadbee;
5118     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5119     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5120     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5121     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5122
5123     state = 0xdeadbee;
5124     action = 0xdeadbee;
5125     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5126     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5127     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5128     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5129
5130     state = 0xdeadbee;
5131     action = 0xdeadbee;
5132     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5133     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5134     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5135     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5136
5137     state = 0xdeadbee;
5138     action = 0xdeadbee;
5139     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5140     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5141     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5142     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5143
5144     state = 0xdeadbee;
5145     action = 0xdeadbee;
5146     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5147     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5148     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5149     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5150
5151     state = 0xdeadbee;
5152     action = 0xdeadbee;
5153     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5154     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5155     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5156     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5157
5158     state = 0xdeadbee;
5159     action = 0xdeadbee;
5160     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5161     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5162     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5163     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5164
5165     state = 0xdeadbee;
5166     action = 0xdeadbee;
5167     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5168     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5169     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5170     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5171
5172     state = 0xdeadbee;
5173     action = 0xdeadbee;
5174     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5176     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5177     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5178
5179     state = 0xdeadbee;
5180     action = 0xdeadbee;
5181     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5182     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5183     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5184     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5185
5186     state = 0xdeadbee;
5187     action = 0xdeadbee;
5188     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5189     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5190     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5191     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5192
5193     state = 0xdeadbee;
5194     action = 0xdeadbee;
5195     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5196     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5197     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5198     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5199
5200     state = 0xdeadbee;
5201     action = 0xdeadbee;
5202     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5203     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5204     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5205     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5206
5207     state = 0xdeadbee;
5208     action = 0xdeadbee;
5209     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5210     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5211     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5212     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5213
5214     state = 0xdeadbee;
5215     action = 0xdeadbee;
5216     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5217     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5218     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5219     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5220
5221     state = 0xdeadbee;
5222     action = 0xdeadbee;
5223     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5224     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5225     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5226     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5227
5228     state = 0xdeadbee;
5229     action = 0xdeadbee;
5230     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5231     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5232     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5233     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5234
5235     state = 0xdeadbee;
5236     action = 0xdeadbee;
5237     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5238     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5239     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5240     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5241
5242     state = 0xdeadbee;
5243     action = 0xdeadbee;
5244     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5245     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5246     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5247     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5248
5249     r = MsiDoAction( hpkg, "FileCost");
5250     ok( r == ERROR_SUCCESS, "file cost failed\n");
5251
5252     state = 0xdeadbee;
5253     action = 0xdeadbee;
5254     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5255     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5256     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5257     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5258
5259     state = 0xdeadbee;
5260     action = 0xdeadbee;
5261     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5262     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5263     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5264     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5265
5266     state = 0xdeadbee;
5267     action = 0xdeadbee;
5268     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5269     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5270     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5271     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5272
5273     state = 0xdeadbee;
5274     action = 0xdeadbee;
5275     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5276     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5277     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5278     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5279
5280     state = 0xdeadbee;
5281     action = 0xdeadbee;
5282     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5283     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5284     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5285     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5286
5287     state = 0xdeadbee;
5288     action = 0xdeadbee;
5289     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5290     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5291     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5292     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5293
5294     state = 0xdeadbee;
5295     action = 0xdeadbee;
5296     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5297     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5298     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5299     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5300
5301     state = 0xdeadbee;
5302     action = 0xdeadbee;
5303     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5304     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5305     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5306     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5307
5308     state = 0xdeadbee;
5309     action = 0xdeadbee;
5310     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5311     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5312     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5313     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5314
5315     state = 0xdeadbee;
5316     action = 0xdeadbee;
5317     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5318     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5319     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5320     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5321
5322     state = 0xdeadbee;
5323     action = 0xdeadbee;
5324     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5326     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5327     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5328
5329     state = 0xdeadbee;
5330     action = 0xdeadbee;
5331     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5332     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5333     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5334     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5335
5336     state = 0xdeadbee;
5337     action = 0xdeadbee;
5338     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5339     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5340     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5341     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5342
5343     state = 0xdeadbee;
5344     action = 0xdeadbee;
5345     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5346     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5347     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5348     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5349
5350     state = 0xdeadbee;
5351     action = 0xdeadbee;
5352     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5353     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5354     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5355     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5356
5357     state = 0xdeadbee;
5358     action = 0xdeadbee;
5359     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5360     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5361     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5362     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5363
5364     state = 0xdeadbee;
5365     action = 0xdeadbee;
5366     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5367     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5368     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5369     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5370
5371     state = 0xdeadbee;
5372     action = 0xdeadbee;
5373     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5374     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5375     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5376     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5377
5378     state = 0xdeadbee;
5379     action = 0xdeadbee;
5380     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5381     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5382     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5383     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5384
5385     state = 0xdeadbee;
5386     action = 0xdeadbee;
5387     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5388     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5389     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5390     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5391
5392     state = 0xdeadbee;
5393     action = 0xdeadbee;
5394     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5395     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5396     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5397     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5398
5399     state = 0xdeadbee;
5400     action = 0xdeadbee;
5401     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5402     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5403     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5404     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5405
5406     state = 0xdeadbee;
5407     action = 0xdeadbee;
5408     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5409     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5410     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5411     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5412
5413     state = 0xdeadbee;
5414     action = 0xdeadbee;
5415     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5416     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5417     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5418     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5419
5420     state = 0xdeadbee;
5421     action = 0xdeadbee;
5422     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5423     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5424     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5425     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5426
5427     r = MsiDoAction( hpkg, "CostFinalize");
5428     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
5429
5430     state = 0xdeadbee;
5431     action = 0xdeadbee;
5432     r = MsiGetFeatureState(hpkg, "one", &state, &action);
5433     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5434     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5435     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5436
5437     state = 0xdeadbee;
5438     action = 0xdeadbee;
5439     r = MsiGetFeatureState(hpkg, "two", &state, &action);
5440     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5441     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5442     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5443
5444     state = 0xdeadbee;
5445     action = 0xdeadbee;
5446     r = MsiGetFeatureState(hpkg, "three", &state, &action);
5447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5448     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5449     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5450
5451     state = 0xdeadbee;
5452     action = 0xdeadbee;
5453     r = MsiGetFeatureState(hpkg, "four", &state, &action);
5454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5455     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5456     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5457
5458     state = 0xdeadbee;
5459     action = 0xdeadbee;
5460     r = MsiGetFeatureState(hpkg, "five", &state, &action);
5461     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5462     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5463     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5464
5465     state = 0xdeadbee;
5466     action = 0xdeadbee;
5467     r = MsiGetFeatureState(hpkg, "six", &state, &action);
5468     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5469     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5470     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5471
5472     state = 0xdeadbee;
5473     action = 0xdeadbee;
5474     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
5475     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5476     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5477     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5478
5479     state = 0xdeadbee;
5480     action = 0xdeadbee;
5481     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
5482     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5483     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5484     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5485
5486     state = 0xdeadbee;
5487     action = 0xdeadbee;
5488     r = MsiGetComponentState(hpkg, "beta", &state, &action);
5489     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5490     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5491     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5492
5493     state = 0xdeadbee;
5494     action = 0xdeadbee;
5495     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
5496     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5497     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5498     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5499
5500     state = 0xdeadbee;
5501     action = 0xdeadbee;
5502     r = MsiGetComponentState(hpkg, "theta", &state, &action);
5503     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5504     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5505     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5506
5507     state = 0xdeadbee;
5508     action = 0xdeadbee;
5509     r = MsiGetComponentState(hpkg, "delta", &state, &action);
5510     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5511     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5512     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5513
5514     state = 0xdeadbee;
5515     action = 0xdeadbee;
5516     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
5517     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5518     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5519     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5520
5521     state = 0xdeadbee;
5522     action = 0xdeadbee;
5523     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
5524     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5525     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5526     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5527
5528     state = 0xdeadbee;
5529     action = 0xdeadbee;
5530     r = MsiGetComponentState(hpkg, "iota", &state, &action);
5531     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5532     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5533     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5534
5535     state = 0xdeadbee;
5536     action = 0xdeadbee;
5537     r = MsiGetComponentState(hpkg, "eta", &state, &action);
5538     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5539     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5540     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
5541
5542     state = 0xdeadbee;
5543     action = 0xdeadbee;
5544     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
5545     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5546     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
5547     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5548
5549     state = 0xdeadbee;
5550     action = 0xdeadbee;
5551     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
5552     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5553     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5554     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5555
5556     state = 0xdeadbee;
5557     action = 0xdeadbee;
5558     r = MsiGetComponentState(hpkg, "mu", &state, &action);
5559     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5560     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5561     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5562
5563     state = 0xdeadbee;
5564     action = 0xdeadbee;
5565     r = MsiGetComponentState(hpkg, "nu", &state, &action);
5566     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5567     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5568     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5569
5570     state = 0xdeadbee;
5571     action = 0xdeadbee;
5572     r = MsiGetComponentState(hpkg, "xi", &state, &action);
5573     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5574     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5575     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5576
5577     state = 0xdeadbee;
5578     action = 0xdeadbee;
5579     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
5580     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5581     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5582     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5583
5584     state = 0xdeadbee;
5585     action = 0xdeadbee;
5586     r = MsiGetComponentState(hpkg, "pi", &state, &action);
5587     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5588     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5589     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5590
5591     state = 0xdeadbee;
5592     action = 0xdeadbee;
5593     r = MsiGetComponentState(hpkg, "rho", &state, &action);
5594     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5595     ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
5596     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
5597
5598     state = 0xdeadbee;
5599     action = 0xdeadbee;
5600     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
5601     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
5602     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5603     ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5604
5605     MsiCloseHandle(hpkg);
5606
5607     /* uninstall the product */
5608     r = MsiInstallProduct(msifile3, "REMOVE=ALL");
5609     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5610
5611     DeleteFileA(msifile);
5612     DeleteFileA(msifile2);
5613     DeleteFileA(msifile3);
5614 }
5615
5616 static void test_getproperty(void)
5617 {
5618     MSIHANDLE hPackage = 0;
5619     char prop[100];
5620     static CHAR empty[] = "";
5621     DWORD size;
5622     UINT r;
5623
5624     hPackage = package_from_db(create_package_db());
5625     ok( hPackage != 0, " Failed to create package\n");
5626
5627     /* set the property */
5628     r = MsiSetProperty(hPackage, "Name", "Value");
5629     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5630
5631     /* retrieve the size, NULL pointer */
5632     size = 0;
5633     r = MsiGetProperty(hPackage, "Name", NULL, &size);
5634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5635     ok( size == 5, "Expected 5, got %d\n", size);
5636
5637     /* retrieve the size, empty string */
5638     size = 0;
5639     r = MsiGetProperty(hPackage, "Name", empty, &size);
5640     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
5641     ok( size == 5, "Expected 5, got %d\n", size);
5642
5643     /* don't change size */
5644     r = MsiGetProperty(hPackage, "Name", prop, &size);
5645     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
5646     ok( size == 5, "Expected 5, got %d\n", size);
5647     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
5648
5649     /* increase the size by 1 */
5650     size++;
5651     r = MsiGetProperty(hPackage, "Name", prop, &size);
5652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5653     ok( size == 5, "Expected 5, got %d\n", size);
5654     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
5655
5656     r = MsiCloseHandle( hPackage);
5657     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
5658     DeleteFile(msifile);
5659 }
5660
5661 static void test_removefiles(void)
5662 {
5663     MSIHANDLE hpkg;
5664     UINT r;
5665     MSIHANDLE hdb;
5666
5667     hdb = create_package_db();
5668     ok ( hdb, "failed to create package database\n" );
5669
5670     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5671     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5672
5673     r = create_feature_table( hdb );
5674     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5675
5676     r = create_component_table( hdb );
5677     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5678
5679     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
5680     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5681
5682     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
5683     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5684
5685     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
5686     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5687
5688     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
5689     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5690
5691     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
5692     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5693
5694     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
5695     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5696
5697     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
5698     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5699
5700     r = create_feature_components_table( hdb );
5701     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5702
5703     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
5704     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5705
5706     r = add_feature_components_entry( hdb, "'one', 'helium'" );
5707     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5708
5709     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
5710     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5711
5712     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
5713     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5714
5715     r = add_feature_components_entry( hdb, "'one', 'boron'" );
5716     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5717
5718     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
5719     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5720
5721     r = create_file_table( hdb );
5722     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5723
5724     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
5725     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5726
5727     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
5728     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5729
5730     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
5731     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5732
5733     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
5734     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5735
5736     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
5737     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5738
5739     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
5740     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5741
5742     r = create_remove_file_table( hdb );
5743     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
5744
5745     hpkg = package_from_db( hdb );
5746     ok( hpkg, "failed to create package\n");
5747
5748     MsiCloseHandle( hdb );
5749
5750     create_test_file( "hydrogen.txt" );
5751     create_test_file( "helium.txt" );
5752     create_test_file( "lithium.txt" );
5753     create_test_file( "beryllium.txt" );
5754     create_test_file( "boron.txt" );
5755     create_test_file( "carbon.txt" );
5756
5757     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
5758     ok( r == ERROR_SUCCESS, "set property failed\n");
5759
5760     r = MsiDoAction( hpkg, "CostInitialize");
5761     ok( r == ERROR_SUCCESS, "cost init failed\n");
5762
5763     r = MsiDoAction( hpkg, "FileCost");
5764     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5765
5766     r = MsiDoAction( hpkg, "CostFinalize");
5767     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5768
5769     r = MsiDoAction( hpkg, "InstallValidate");
5770     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5771
5772     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
5773     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5774
5775     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
5776     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5777
5778     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
5779     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5780
5781     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
5782     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5783
5784     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
5785     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5786
5787     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
5788     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
5789
5790     r = MsiDoAction( hpkg, "RemoveFiles");
5791     ok( r == ERROR_SUCCESS, "remove files failed\n");
5792
5793     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
5794     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
5795     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
5796     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
5797     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
5798     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
5799
5800     MsiCloseHandle( hpkg );
5801     DeleteFileA(msifile);
5802 }
5803
5804 static void test_appsearch(void)
5805 {
5806     MSIHANDLE hpkg;
5807     UINT r;
5808     MSIHANDLE hdb;
5809     CHAR prop[MAX_PATH];
5810     DWORD size = MAX_PATH;
5811
5812     hdb = create_package_db();
5813     ok ( hdb, "failed to create package database\n" );
5814
5815     r = create_appsearch_table( hdb );
5816     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
5817
5818     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
5819     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
5820
5821     r = create_reglocator_table( hdb );
5822     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
5823
5824     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
5825     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
5826
5827     r = create_signature_table( hdb );
5828     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
5829
5830     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
5831     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
5832
5833     hpkg = package_from_db( hdb );
5834     ok( hpkg, "failed to create package\n");
5835
5836     MsiCloseHandle( hdb );
5837
5838     r = MsiDoAction( hpkg, "AppSearch" );
5839     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
5840
5841     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
5842     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
5843     todo_wine
5844     {
5845         ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
5846     }
5847
5848     MsiCloseHandle( hpkg );
5849     DeleteFileA(msifile);
5850 }
5851
5852 static void test_appsearch_complocator(void)
5853 {
5854     MSIHANDLE hpkg, hdb;
5855     CHAR path[MAX_PATH];
5856     CHAR prop[MAX_PATH];
5857     LPSTR usersid;
5858     DWORD size;
5859     UINT r;
5860
5861     get_user_sid(&usersid);
5862     if (!usersid)
5863     {
5864         skip("ConvertSidToStringSidA is not available\n");
5865         return;
5866     }
5867
5868     create_test_file("FileName1");
5869     create_test_file("FileName4");
5870     set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
5871                        "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
5872
5873     create_test_file("FileName2");
5874     set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
5875                        "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
5876
5877     create_test_file("FileName3");
5878     set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
5879                        "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
5880
5881     create_test_file("FileName5");
5882     set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
5883                        "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
5884
5885     create_test_file("FileName6");
5886     set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
5887                        "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
5888
5889     create_test_file("FileName7");
5890     set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
5891                        "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
5892
5893     /* dir is FALSE, but we're pretending it's a directory */
5894     set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
5895                        "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
5896
5897     create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5898     set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
5899                        "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
5900
5901     create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5902     set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
5903                        "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
5904
5905     create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5906     set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
5907                        "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
5908
5909     hdb = create_package_db();
5910     ok(hdb, "Expected a valid database handle\n");
5911
5912     r = create_appsearch_table(hdb);
5913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5914
5915     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5916     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5917
5918     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5919     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5920
5921     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5922     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5923
5924     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5925     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5926
5927     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5928     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5929
5930     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5931     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5932
5933     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5934     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5935
5936     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5937     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5938
5939     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5940     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5941
5942     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5943     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5944
5945     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5946     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5947
5948     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
5949     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5950
5951     r = create_complocator_table(hdb);
5952     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5953
5954     /* published component, machine, file, signature, misdbLocatorTypeFile */
5955     r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
5956     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5957
5958     /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
5959     r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
5960     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5961
5962     /* published component, user-managed, file, signature, misdbLocatorTypeFile */
5963     r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
5964     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5965
5966     /* published component, machine, file, signature, misdbLocatorTypeDirectory */
5967     r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
5968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5969
5970     /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
5971     r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
5972     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5973
5974     /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
5975     r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
5976     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5977
5978     /* published component, machine, file, no signature, misdbLocatorTypeFile */
5979     r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
5980     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5981
5982     /* unpublished component, no signature, misdbLocatorTypeDir */
5983     r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
5984     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5985
5986     /* published component, no signature, dir does not exist misdbLocatorTypeDir */
5987     r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
5988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5989
5990     /* published component, signature w/ ver, misdbLocatorTypeFile */
5991     r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
5992     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5993
5994     /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
5995     r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
5996     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5997
5998     /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
5999     r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
6000     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6001
6002     r = create_signature_table(hdb);
6003     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6004
6005     r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
6006     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6007
6008     r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
6009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6010
6011     r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
6012     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6013
6014     r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
6015     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6016
6017     r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
6018     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6019
6020     r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
6021     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6022
6023     r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
6024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6025
6026     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
6027     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6028
6029     hpkg = package_from_db(hdb);
6030     ok(hpkg, "Expected a valid package handle\n");
6031
6032     r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
6033     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6034
6035     r = MsiDoAction(hpkg, "AppSearch");
6036     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6037
6038     size = MAX_PATH;
6039     sprintf(path, "%s\\FileName1", CURR_DIR);
6040     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
6041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6042     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6043
6044     size = MAX_PATH;
6045     sprintf(path, "%s\\FileName2", CURR_DIR);
6046     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
6047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6048     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6049
6050     size = MAX_PATH;
6051     sprintf(path, "%s\\FileName3", CURR_DIR);
6052     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
6053     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6054     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6055
6056     size = MAX_PATH;
6057     sprintf(path, "%s\\FileName4", CURR_DIR);
6058     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
6059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6060     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6061
6062     size = MAX_PATH;
6063     sprintf(path, "%s\\FileName5", CURR_DIR);
6064     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
6065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6066     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6067
6068     size = MAX_PATH;
6069     sprintf(path, "%s\\", CURR_DIR);
6070     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
6071     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6072     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6073
6074     size = MAX_PATH;
6075     sprintf(path, "%s\\", CURR_DIR);
6076     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
6077     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6078     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6079
6080     size = MAX_PATH;
6081     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
6082     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6083     ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
6084
6085     size = MAX_PATH;
6086     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
6087     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6088     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6089
6090     size = MAX_PATH;
6091     sprintf(path, "%s\\FileName8.dll", CURR_DIR);
6092     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
6093     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6094     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6095
6096     size = MAX_PATH;
6097     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
6098     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6099     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6100
6101     size = MAX_PATH;
6102     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
6103     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
6104     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6105     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6106
6107     delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
6108                           MSIINSTALLCONTEXT_MACHINE, NULL);
6109     delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
6110                           MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
6111     delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
6112                           MSIINSTALLCONTEXT_USERMANAGED, usersid);
6113     delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
6114                           MSIINSTALLCONTEXT_MACHINE, NULL);
6115     delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
6116                           MSIINSTALLCONTEXT_MACHINE, NULL);
6117     delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
6118                           MSIINSTALLCONTEXT_MACHINE, NULL);
6119     delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
6120                           MSIINSTALLCONTEXT_MACHINE, NULL);
6121     delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
6122                           MSIINSTALLCONTEXT_MACHINE, NULL);
6123     delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
6124                           MSIINSTALLCONTEXT_MACHINE, NULL);
6125     delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
6126                           MSIINSTALLCONTEXT_MACHINE, NULL);
6127
6128     DeleteFileA("FileName1");
6129     DeleteFileA("FileName2");
6130     DeleteFileA("FileName3");
6131     DeleteFileA("FileName4");
6132     DeleteFileA("FileName5");
6133     DeleteFileA("FileName6");
6134     DeleteFileA("FileName7");
6135     DeleteFileA("FileName8.dll");
6136     DeleteFileA("FileName9.dll");
6137     DeleteFileA("FileName10.dll");
6138     MsiCloseHandle(hpkg);
6139     DeleteFileA(msifile);
6140 }
6141
6142 static void test_appsearch_reglocator(void)
6143 {
6144     MSIHANDLE hpkg, hdb;
6145     CHAR path[MAX_PATH];
6146     CHAR prop[MAX_PATH];
6147     DWORD binary[2];
6148     DWORD size, val;
6149     HKEY hklm, classes;
6150     HKEY hkcu, users;
6151     LPCSTR str;
6152     LONG res;
6153     UINT r;
6154
6155     res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
6156     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6157
6158     res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
6159                          (const BYTE *)"regszdata", 10);
6160     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6161
6162     res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
6163     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6164
6165     res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
6166                          (const BYTE *)"regszdata", 10);
6167     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6168
6169     res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
6170     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6171
6172     res = RegSetValueExA(users, "Value1", 0, REG_SZ,
6173                          (const BYTE *)"regszdata", 10);
6174     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6175
6176     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
6177     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6178
6179     res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
6180     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6181
6182     res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
6183                          (const BYTE *)"regszdata", 10);
6184     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6185
6186     val = 42;
6187     res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
6188                          (const BYTE *)&val, sizeof(DWORD));
6189     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6190
6191     val = -42;
6192     res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
6193                          (const BYTE *)&val, sizeof(DWORD));
6194     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6195
6196     res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
6197                          (const BYTE *)"%PATH%", 7);
6198     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6199
6200     res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
6201                          (const BYTE *)"my%NOVAR%", 10);
6202     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6203
6204     res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
6205                          (const BYTE *)"one\0two\0", 9);
6206     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6207
6208     binary[0] = 0x1234abcd;
6209     binary[1] = 0x567890ef;
6210     res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
6211                          (const BYTE *)binary, sizeof(binary));
6212     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6213
6214     res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
6215                          (const BYTE *)"#regszdata", 11);
6216     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6217
6218     create_test_file("FileName1");
6219     sprintf(path, "%s\\FileName1", CURR_DIR);
6220     res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
6221                          (const BYTE *)path, lstrlenA(path) + 1);
6222     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6223
6224     sprintf(path, "%s\\FileName2", CURR_DIR);
6225     res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
6226                          (const BYTE *)path, lstrlenA(path) + 1);
6227     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6228
6229     lstrcpyA(path, CURR_DIR);
6230     res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
6231                          (const BYTE *)path, lstrlenA(path) + 1);
6232     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6233
6234     res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
6235                          (const BYTE *)"", 1);
6236     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6237
6238     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
6239     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
6240     res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
6241                          (const BYTE *)path, lstrlenA(path) + 1);
6242     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6243
6244     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
6245     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
6246     res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
6247                          (const BYTE *)path, lstrlenA(path) + 1);
6248     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6249
6250     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
6251     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
6252     res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
6253                          (const BYTE *)path, lstrlenA(path) + 1);
6254     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6255
6256     hdb = create_package_db();
6257     ok(hdb, "Expected a valid database handle\n");
6258
6259     r = create_appsearch_table(hdb);
6260     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6261
6262     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
6263     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6264
6265     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
6266     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6267
6268     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
6269     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6270
6271     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
6272     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6273
6274     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
6275     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6276
6277     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
6278     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6279
6280     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
6281     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6282
6283     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
6284     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6285
6286     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
6287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6288
6289     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
6290     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6291
6292     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
6293     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6294
6295     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
6296     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6297
6298     r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
6299     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6300
6301     r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
6302     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6303
6304     r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
6305     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6306
6307     r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
6308     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6309
6310     r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
6311     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6312
6313     r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
6314     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6315
6316     r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
6317     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6318
6319     r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
6320     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6321
6322     r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
6323     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6324
6325     r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
6326     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6327
6328     r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
6329     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6330
6331     r = create_reglocator_table(hdb);
6332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6333
6334     /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
6335     str = "'NewSignature1', 2, 'Software\\Wine', 'Value1', 2";
6336     r = add_reglocator_entry(hdb, str);
6337     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6338
6339     /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
6340     str = "'NewSignature2', 2, 'Software\\Wine', 'Value2', 2";
6341     r = add_reglocator_entry(hdb, str);
6342     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6343
6344     /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
6345     str = "'NewSignature3', 2, 'Software\\Wine', 'Value3', 2";
6346     r = add_reglocator_entry(hdb, str);
6347     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6348
6349     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
6350     str = "'NewSignature4', 2, 'Software\\Wine', 'Value4', 2";
6351     r = add_reglocator_entry(hdb, str);
6352     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6353
6354     /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
6355     str = "'NewSignature5', 2, 'Software\\Wine', 'Value5', 2";
6356     r = add_reglocator_entry(hdb, str);
6357     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6358
6359     /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
6360     str = "'NewSignature6', 2, 'Software\\Wine', 'Value6', 2";
6361     r = add_reglocator_entry(hdb, str);
6362     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6363
6364     /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
6365     str = "'NewSignature7', 2, 'Software\\Wine', 'Value7', 2";
6366     r = add_reglocator_entry(hdb, str);
6367     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6368
6369     /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
6370     str = "'NewSignature8', 2, 'Software\\Wine', 'Value8', 2";
6371     r = add_reglocator_entry(hdb, str);
6372     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6373
6374     /* HKLM, msidbLocatorTypeFileName, file exists */
6375     str = "'NewSignature9', 2, 'Software\\Wine', 'Value9', 1";
6376     r = add_reglocator_entry(hdb, str);
6377     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6378
6379     /* HKLM, msidbLocatorTypeFileName, file does not exist */
6380     str = "'NewSignature10', 2, 'Software\\Wine', 'Value10', 1";
6381     r = add_reglocator_entry(hdb, str);
6382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6383
6384     /* HKLM, msidbLocatorTypeFileName, no signature */
6385     str = "'NewSignature11', 2, 'Software\\Wine', 'Value9', 1";
6386     r = add_reglocator_entry(hdb, str);
6387     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6388
6389     /* HKLM, msidbLocatorTypeDirectory, file exists */
6390     str = "'NewSignature12', 2, 'Software\\Wine', 'Value9', 0";
6391     r = add_reglocator_entry(hdb, str);
6392     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6393
6394     /* HKLM, msidbLocatorTypeDirectory, directory */
6395     str = "'NewSignature13', 2, 'Software\\Wine', 'Value11', 0";
6396     r = add_reglocator_entry(hdb, str);
6397     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6398
6399     /* HKLM, msidbLocatorTypeDirectory, file exists, with signature */
6400     str = "'NewSignature14', 2, 'Software\\Wine', 'Value9', 0";
6401     r = add_reglocator_entry(hdb, str);
6402     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6403
6404     /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
6405     str = "'NewSignature15', 0, 'Software\\Wine', 'Value1', 2";
6406     r = add_reglocator_entry(hdb, str);
6407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6408
6409     /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
6410     str = "'NewSignature16', 1, 'Software\\Wine', 'Value1', 2";
6411     r = add_reglocator_entry(hdb, str);
6412     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6413
6414     /* HKU, msidbLocatorTypeRawValue, REG_SZ */
6415     str = "'NewSignature17', 3, 'S-1-5-18\\Software\\Wine', 'Value1', 2";
6416     r = add_reglocator_entry(hdb, str);
6417     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6418
6419     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
6420     str = "'NewSignature18', 2, 'Software\\Wine', '', 2";
6421     r = add_reglocator_entry(hdb, str);
6422     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6423
6424     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
6425     str = "'NewSignature19', 2, 'Software\\IDontExist', '', 2";
6426     r = add_reglocator_entry(hdb, str);
6427     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6428
6429     /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
6430     str = "'NewSignature20', 2, 'Software\\Wine', 'Value12', 2";
6431     r = add_reglocator_entry(hdb, str);
6432     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6433
6434     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, signature */
6435     str = "'NewSignature21', 2, 'Software\\Wine', 'Value13', 1";
6436     r = add_reglocator_entry(hdb, str);
6437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6438
6439     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
6440     str = "'NewSignature22', 2, 'Software\\Wine', 'Value14', 1";
6441     r = add_reglocator_entry(hdb, str);
6442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6443
6444     /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
6445     str = "'NewSignature23', 2, 'Software\\Wine', 'Value15', 1";
6446     r = add_reglocator_entry(hdb, str);
6447     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6448
6449     r = create_signature_table(hdb);
6450     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6451
6452     str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
6453     r = add_signature_entry(hdb, str);
6454     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6455
6456     str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
6457     r = add_signature_entry(hdb, str);
6458     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6459
6460     str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
6461     r = add_signature_entry(hdb, str);
6462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6463
6464     str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
6465     r = add_signature_entry(hdb, str);
6466     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6467
6468     str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
6469     r = add_signature_entry(hdb, str);
6470     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6471
6472     str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
6473     r = add_signature_entry(hdb, str);
6474     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6475
6476     hpkg = package_from_db(hdb);
6477     ok(hpkg, "Expected a valid package handle\n");
6478
6479     r = MsiDoAction(hpkg, "AppSearch");
6480     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6481
6482     size = MAX_PATH;
6483     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
6484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6485     ok(!lstrcmpA(prop, "regszdata"),
6486        "Expected \"regszdata\", got \"%s\"\n", prop);
6487
6488     size = MAX_PATH;
6489     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
6490     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6491     ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
6492
6493     size = MAX_PATH;
6494     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
6495     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6496     ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
6497
6498     ExpandEnvironmentStringsA("%PATH%", path, MAX_PATH);
6499
6500     size = MAX_PATH;
6501     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
6502     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6503     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6504
6505     size = MAX_PATH;
6506     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
6507     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6508     ok(!lstrcmpA(prop,
6509        "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
6510
6511     size = MAX_PATH;
6512     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
6513     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6514     todo_wine
6515     {
6516         ok(!memcmp(prop, "\0one\0two\0\0", 10),
6517            "Expected \"\\0one\\0two\\0\\0\"\n");
6518     }
6519
6520     size = MAX_PATH;
6521     lstrcpyA(path, "#xCDAB3412EF907856");
6522     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
6523     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6524     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6525
6526     size = MAX_PATH;
6527     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
6528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6529     ok(!lstrcmpA(prop, "##regszdata"),
6530        "Expected \"##regszdata\", got \"%s\"\n", prop);
6531
6532     size = MAX_PATH;
6533     sprintf(path, "%s\\FileName1", CURR_DIR);
6534     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
6535     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6536     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6537
6538     size = MAX_PATH;
6539     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
6540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6541     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6542
6543     size = MAX_PATH;
6544     sprintf(path, "%s\\", CURR_DIR);
6545     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
6546     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6547     todo_wine
6548     {
6549         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6550     }
6551
6552     size = MAX_PATH;
6553     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
6554     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6555     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6556
6557     size = MAX_PATH;
6558     sprintf(path, "%s\\", CURR_DIR);
6559     r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
6560     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6561     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6562
6563     size = MAX_PATH;
6564     r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
6565     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6566     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6567
6568     size = MAX_PATH;
6569     r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
6570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6571     ok(!lstrcmpA(prop, "regszdata"),
6572        "Expected \"regszdata\", got \"%s\"\n", prop);
6573
6574     size = MAX_PATH;
6575     r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
6576     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6577     ok(!lstrcmpA(prop, "regszdata"),
6578        "Expected \"regszdata\", got \"%s\"\n", prop);
6579
6580     size = MAX_PATH;
6581     r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
6582     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6583     ok(!lstrcmpA(prop, "regszdata"),
6584        "Expected \"regszdata\", got \"%s\"\n", prop);
6585
6586     size = MAX_PATH;
6587     r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
6588     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6589     ok(!lstrcmpA(prop, "defvalue"),
6590        "Expected \"defvalue\", got \"%s\"\n", prop);
6591
6592     size = MAX_PATH;
6593     r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
6594     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6595     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6596
6597     size = MAX_PATH;
6598     r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
6599     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6600     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6601
6602     size = MAX_PATH;
6603     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
6604     r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
6605     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6606     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6607
6608     size = MAX_PATH;
6609     r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
6610     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6611     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6612
6613     size = MAX_PATH;
6614     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
6615     r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
6616     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6617     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6618
6619     RegSetValueA(hklm, NULL, REG_SZ, "", 0);
6620     RegDeleteValueA(hklm, "Value1");
6621     RegDeleteValueA(hklm, "Value2");
6622     RegDeleteValueA(hklm, "Value3");
6623     RegDeleteValueA(hklm, "Value4");
6624     RegDeleteValueA(hklm, "Value5");
6625     RegDeleteValueA(hklm, "Value6");
6626     RegDeleteValueA(hklm, "Value7");
6627     RegDeleteValueA(hklm, "Value8");
6628     RegDeleteValueA(hklm, "Value9");
6629     RegDeleteValueA(hklm, "Value10");
6630     RegDeleteValueA(hklm, "Value11");
6631     RegDeleteValueA(hklm, "Value12");
6632     RegDeleteValueA(hklm, "Value13");
6633     RegDeleteValueA(hklm, "Value14");
6634     RegDeleteValueA(hklm, "Value15");
6635     RegDeleteKeyA(hklm, "");
6636     RegCloseKey(hklm);
6637
6638     RegDeleteValueA(classes, "Value1");
6639     RegDeleteKeyA(classes, "");
6640     RegCloseKey(classes);
6641
6642     RegDeleteValueA(hkcu, "Value1");
6643     RegDeleteKeyA(hkcu, "");
6644     RegCloseKey(hkcu);
6645
6646     RegDeleteValueA(users, "Value1");
6647     RegDeleteKeyA(users, "");
6648     RegCloseKey(users);
6649
6650     DeleteFileA("FileName1");
6651     DeleteFileA("FileName3.dll");
6652     DeleteFileA("FileName4.dll");
6653     DeleteFileA("FileName5.dll");
6654     MsiCloseHandle(hpkg);
6655     DeleteFileA(msifile);
6656 }
6657
6658 static void delete_win_ini(LPCSTR file)
6659 {
6660     CHAR path[MAX_PATH];
6661
6662     GetWindowsDirectoryA(path, MAX_PATH);
6663     lstrcatA(path, "\\");
6664     lstrcatA(path, file);
6665
6666     DeleteFileA(path);
6667 }
6668
6669 static void test_appsearch_inilocator(void)
6670 {
6671     MSIHANDLE hpkg, hdb;
6672     CHAR path[MAX_PATH];
6673     CHAR prop[MAX_PATH];
6674     LPCSTR str;
6675     LPSTR ptr;
6676     DWORD size;
6677     UINT r;
6678
6679     WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
6680
6681     create_test_file("FileName1");
6682     sprintf(path, "%s\\FileName1", CURR_DIR);
6683     WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
6684
6685     WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
6686
6687     sprintf(path, "%s\\IDontExist", CURR_DIR);
6688     WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
6689
6690     create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
6691     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
6692     WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
6693
6694     create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
6695     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
6696     WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
6697
6698     create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
6699     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
6700     WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
6701
6702     hdb = create_package_db();
6703     ok(hdb, "Expected a valid database handle\n");
6704
6705     r = create_appsearch_table(hdb);
6706     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6707
6708     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
6709     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6710
6711     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
6712     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6713
6714     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
6715     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6716
6717     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
6718     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6719
6720     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
6721     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6722
6723     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
6724     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6725
6726     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
6727     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6728
6729     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
6730     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6731
6732     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
6733     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6734
6735     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
6736     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6737
6738     r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
6739     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6740
6741     r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
6742     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6743
6744     r = create_inilocator_table(hdb);
6745     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6746
6747     /* msidbLocatorTypeRawValue, field 1 */
6748     str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
6749     r = add_inilocator_entry(hdb, str);
6750     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6751
6752     /* msidbLocatorTypeRawValue, field 2 */
6753     str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
6754     r = add_inilocator_entry(hdb, str);
6755     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6756
6757     /* msidbLocatorTypeRawValue, entire field */
6758     str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
6759     r = add_inilocator_entry(hdb, str);
6760     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6761
6762     /* msidbLocatorTypeFile */
6763     str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
6764     r = add_inilocator_entry(hdb, str);
6765     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6766
6767     /* msidbLocatorTypeDirectory, file */
6768     str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
6769     r = add_inilocator_entry(hdb, str);
6770     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6771
6772     /* msidbLocatorTypeDirectory, directory */
6773     str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
6774     r = add_inilocator_entry(hdb, str);
6775     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6776
6777     /* msidbLocatorTypeFile, file, no signature */
6778     str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
6779     r = add_inilocator_entry(hdb, str);
6780     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6781
6782     /* msidbLocatorTypeFile, dir, no signature */
6783     str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
6784     r = add_inilocator_entry(hdb, str);
6785     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6786
6787     /* msidbLocatorTypeFile, file does not exist */
6788     str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
6789     r = add_inilocator_entry(hdb, str);
6790     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6791
6792     /* msidbLocatorTypeFile, signature with version */
6793     str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
6794     r = add_inilocator_entry(hdb, str);
6795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6796
6797     /* msidbLocatorTypeFile, signature with version, ver > max */
6798     str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
6799     r = add_inilocator_entry(hdb, str);
6800     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6801
6802     /* msidbLocatorTypeFile, signature with version, sig->name ignored */
6803     str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
6804     r = add_inilocator_entry(hdb, str);
6805     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6806
6807     r = create_signature_table(hdb);
6808     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6809
6810     r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
6811     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6812
6813     r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
6814     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6815
6816     r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
6817     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6818
6819     r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
6820     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6821
6822     r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
6823     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6824
6825     hpkg = package_from_db(hdb);
6826     ok(hpkg, "Expected a valid package handle\n");
6827
6828     r = MsiDoAction(hpkg, "AppSearch");
6829     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6830
6831     size = MAX_PATH;
6832     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
6833     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6834     ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
6835
6836     size = MAX_PATH;
6837     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
6838     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6839     ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
6840
6841     size = MAX_PATH;
6842     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
6843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6844     ok(!lstrcmpA(prop, "keydata,field2"),
6845        "Expected \"keydata,field2\", got \"%s\"\n", prop);
6846
6847     size = MAX_PATH;
6848     sprintf(path, "%s\\FileName1", CURR_DIR);
6849     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
6850     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6851     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6852
6853     size = MAX_PATH;
6854     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
6855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6856     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6857
6858     size = MAX_PATH;
6859     sprintf(path, "%s\\", CURR_DIR);
6860     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
6861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6862     todo_wine
6863     {
6864         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6865     }
6866
6867     size = MAX_PATH;
6868     sprintf(path, "%s\\", CURR_DIR);
6869     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
6870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6871     todo_wine
6872     {
6873         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6874     }
6875
6876     size = MAX_PATH;
6877     lstrcpyA(path, CURR_DIR);
6878     ptr = strrchr(path, '\\');
6879     *(ptr + 1) = '\0';
6880     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
6881     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6882     todo_wine
6883     {
6884         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6885     }
6886
6887     size = MAX_PATH;
6888     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
6889     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6890     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6891
6892     size = MAX_PATH;
6893     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
6894     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
6895     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6896     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6897
6898     size = MAX_PATH;
6899     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
6900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6901     ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
6902
6903     size = MAX_PATH;
6904     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
6905     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
6906     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6907     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
6908
6909     delete_win_ini("IniFile.ini");
6910     DeleteFileA("FileName1");
6911     DeleteFileA("FileName2.dll");
6912     DeleteFileA("FileName3.dll");
6913     DeleteFileA("FileName4.dll");
6914     MsiCloseHandle(hpkg);
6915     DeleteFileA(msifile);
6916 }
6917
6918 static void test_appsearch_drlocator(void)
6919 {
6920     MSIHANDLE hpkg, hdb;
6921     CHAR path[MAX_PATH];
6922     CHAR prop[MAX_PATH];
6923     LPCSTR str;
6924     DWORD size;
6925     UINT r;
6926
6927     create_test_file("FileName1");
6928     CreateDirectoryA("one", NULL);
6929     CreateDirectoryA("one\\two", NULL);
6930     CreateDirectoryA("one\\two\\three", NULL);
6931     create_test_file("one\\two\\three\\FileName2");
6932     CreateDirectoryA("another", NULL);
6933     create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
6934     create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
6935     create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
6936
6937     hdb = create_package_db();
6938     ok(hdb, "Expected a valid database handle\n");
6939
6940     r = create_appsearch_table(hdb);
6941     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6942
6943     r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
6944     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6945
6946     r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
6947     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6948
6949     r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
6950     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6951
6952     r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
6953     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6954
6955     r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
6956     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6957
6958     r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
6959     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6960
6961     r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
6962     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6963
6964     r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
6965     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6966
6967     r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
6968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6969
6970     r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
6971     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6972
6973     r = create_drlocator_table(hdb);
6974     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6975
6976     /* no parent, full path, depth 0, signature */
6977     sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
6978     r = add_drlocator_entry(hdb, path);
6979     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6980
6981     /* no parent, full path, depth 0, no signature */
6982     sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
6983     r = add_drlocator_entry(hdb, path);
6984     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6985
6986     /* no parent, relative path, depth 0, no signature */
6987     sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
6988     r = add_drlocator_entry(hdb, path);
6989     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6990
6991     /* no parent, full path, depth 2, signature */
6992     sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
6993     r = add_drlocator_entry(hdb, path);
6994     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6995
6996     /* no parent, full path, depth 3, signature */
6997     sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
6998     r = add_drlocator_entry(hdb, path);
6999     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7000
7001     /* no parent, full path, depth 1, signature is dir */
7002     sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
7003     r = add_drlocator_entry(hdb, path);
7004     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7005
7006     /* parent is in DrLocator, relative path, depth 0, signature */
7007     sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
7008     r = add_drlocator_entry(hdb, path);
7009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7010
7011     /* no parent, full path, depth 0, signature w/ version */
7012     sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
7013     r = add_drlocator_entry(hdb, path);
7014     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7015
7016     /* no parent, full path, depth 0, signature w/ version, ver > max */
7017     sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
7018     r = add_drlocator_entry(hdb, path);
7019     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7020
7021     /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
7022     sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
7023     r = add_drlocator_entry(hdb, path);
7024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7025
7026     r = create_signature_table(hdb);
7027     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7028
7029     str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
7030     r = add_signature_entry(hdb, str);
7031     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7032
7033     str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
7034     r = add_signature_entry(hdb, str);
7035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7036
7037     str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
7038     r = add_signature_entry(hdb, str);
7039     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7040
7041     str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
7042     r = add_signature_entry(hdb, str);
7043     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7044
7045     str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
7046     r = add_signature_entry(hdb, str);
7047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7048
7049     str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
7050     r = add_signature_entry(hdb, str);
7051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7052
7053     str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
7054     r = add_signature_entry(hdb, str);
7055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7056
7057     str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
7058     r = add_signature_entry(hdb, str);
7059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7060
7061     hpkg = package_from_db(hdb);
7062     ok(hpkg, "Expected a valid package handle\n");
7063
7064     r = MsiDoAction(hpkg, "AppSearch");
7065     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7066
7067     size = MAX_PATH;
7068     sprintf(path, "%s\\FileName1", CURR_DIR);
7069     r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
7070     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7071     todo_wine
7072     {
7073         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7074     }
7075
7076     size = MAX_PATH;
7077     sprintf(path, "%s\\", CURR_DIR);
7078     r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
7079     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7080     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7081
7082     size = MAX_PATH;
7083     sprintf(path, "%s\\", CURR_DIR);
7084     r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
7085     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7086     ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7087
7088     size = MAX_PATH;
7089     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
7090     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7091     todo_wine
7092     {
7093         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7094     }
7095
7096     size = MAX_PATH;
7097     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
7098     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
7099     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7100     todo_wine
7101     {
7102         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7103     }
7104
7105     size = MAX_PATH;
7106     r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
7107     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7108     todo_wine
7109     {
7110         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7111     }
7112
7113     size = MAX_PATH;
7114     sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
7115     r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
7116     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7117     todo_wine
7118     {
7119         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7120     }
7121
7122     size = MAX_PATH;
7123     sprintf(path, "%s\\FileName3.dll", CURR_DIR);
7124     r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
7125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7126     todo_wine
7127     {
7128         ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
7129     }
7130
7131     size = MAX_PATH;
7132     r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
7133     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7134     todo_wine
7135     {
7136         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7137     }
7138
7139     size = MAX_PATH;
7140     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
7141     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7142     todo_wine
7143     {
7144         ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
7145     }
7146
7147     DeleteFileA("FileName1");
7148     DeleteFileA("FileName3.dll");
7149     DeleteFileA("FileName4.dll");
7150     DeleteFileA("FileName5.dll");
7151     DeleteFileA("one\\two\\three\\FileName2");
7152     RemoveDirectoryA("one\\two\\three");
7153     RemoveDirectoryA("one\\two");
7154     RemoveDirectoryA("one");
7155     RemoveDirectoryA("another");
7156     MsiCloseHandle(hpkg);
7157     DeleteFileA(msifile);
7158 }
7159
7160 static void test_featureparents(void)
7161 {
7162     MSIHANDLE hpkg;
7163     UINT r;
7164     MSIHANDLE hdb;
7165     INSTALLSTATE state, action;
7166
7167     hdb = create_package_db();
7168     ok ( hdb, "failed to create package database\n" );
7169
7170     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
7171     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
7172
7173     r = create_feature_table( hdb );
7174     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
7175
7176     r = create_component_table( hdb );
7177     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
7178
7179     r = create_feature_components_table( hdb );
7180     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
7181
7182     r = create_file_table( hdb );
7183     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
7184
7185     /* msidbFeatureAttributesFavorLocal */
7186     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
7187     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7188
7189     /* msidbFeatureAttributesFavorSource */
7190     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
7191     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7192
7193     /* msidbFeatureAttributesFavorLocal */
7194     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
7195     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7196
7197     /* disabled because of install level */
7198     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
7199     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7200
7201     /* child feature of disabled feature */
7202     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
7203     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
7204
7205     /* component of disabled feature (install level) */
7206     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
7207     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7208
7209     /* component of disabled child feature (install level) */
7210     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
7211     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7212
7213     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
7214     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
7215     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7216
7217     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
7218     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
7219     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7220
7221     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
7222     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
7223     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7224
7225     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
7226     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
7227     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7228
7229     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
7230     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
7231     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7232
7233     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
7234     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
7235     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7236
7237     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
7238     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
7239     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7240
7241     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
7242     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
7243     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
7244
7245     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
7246     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
7247
7248     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
7249     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7250
7251     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
7252     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7253
7254     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
7255     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7256
7257     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
7258     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7259
7260     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
7261     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7262
7263     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
7264     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7265
7266     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
7267     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7268
7269     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
7270     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7271
7272     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
7273     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7274
7275     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
7276     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7277
7278     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
7279     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7280
7281     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
7282     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7283
7284     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
7285     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7286
7287     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
7288     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7289
7290     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
7291     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7292
7293     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
7294     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7295
7296     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
7297     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
7298
7299     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
7300     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7301
7302     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
7303     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7304
7305     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
7306     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7307
7308     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
7309     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7310
7311     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
7312     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7313
7314     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
7315     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7316
7317     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
7318     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7319
7320     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
7321     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7322
7323     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
7324     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7325
7326     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
7327     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7328
7329     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
7330     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
7331
7332     hpkg = package_from_db( hdb );
7333     ok( hpkg, "failed to create package\n");
7334
7335     MsiCloseHandle( hdb );
7336
7337     r = MsiDoAction( hpkg, "CostInitialize");
7338     ok( r == ERROR_SUCCESS, "cost init failed\n");
7339
7340     r = MsiDoAction( hpkg, "FileCost");
7341     ok( r == ERROR_SUCCESS, "file cost failed\n");
7342
7343     r = MsiDoAction( hpkg, "CostFinalize");
7344     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
7345
7346     state = 0xdeadbee;
7347     action = 0xdeadbee;
7348     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
7349     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7350     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7351     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7352
7353     state = 0xdeadbee;
7354     action = 0xdeadbee;
7355     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
7356     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7357     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7358     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
7359
7360     state = 0xdeadbee;
7361     action = 0xdeadbee;
7362     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
7363     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7364     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7365     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7366
7367     state = 0xdeadbee;
7368     action = 0xdeadbee;
7369     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
7370     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7371     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7372     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7373
7374     state = 0xdeadbee;
7375     action = 0xdeadbee;
7376     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
7377     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7378     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
7379     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
7380
7381     state = 0xdeadbee;
7382     action = 0xdeadbee;
7383     r = MsiGetComponentState(hpkg, "leo", &state, &action);
7384     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7385     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
7386     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
7387
7388     state = 0xdeadbee;
7389     action = 0xdeadbee;
7390     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
7391     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7392     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
7393     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
7394
7395     state = 0xdeadbee;
7396     action = 0xdeadbee;
7397     r = MsiGetComponentState(hpkg, "libra", &state, &action);
7398     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7399     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
7400     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
7401
7402     state = 0xdeadbee;
7403     action = 0xdeadbee;
7404     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
7405     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7406     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
7407     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
7408
7409     state = 0xdeadbee;
7410     action = 0xdeadbee;
7411     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
7412     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7413     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
7414     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
7415
7416     state = 0xdeadbee;
7417     action = 0xdeadbee;
7418     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
7419     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7420     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
7421     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
7422
7423     state = 0xdeadbee;
7424     action = 0xdeadbee;
7425     r = MsiGetComponentState(hpkg, "canis", &state, &action);
7426     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7427     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
7428     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
7429
7430     state = 0xdeadbee;
7431     action = 0xdeadbee;
7432     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
7433     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7434     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
7435     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
7436
7437     state = 0xdeadbee;
7438     action = 0xdeadbee;
7439     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
7440     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7441     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
7442     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
7443
7444     state = 0xdeadbee;
7445     action = 0xdeadbee;
7446     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
7447     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7448     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
7449     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
7450
7451     state = 0xdeadbee;
7452     action = 0xdeadbee;
7453     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
7454     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7455     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
7456     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
7457
7458     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
7459     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
7460
7461     state = 0xdeadbee;
7462     action = 0xdeadbee;
7463     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
7464     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7465     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
7466     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
7467
7468     state = 0xdeadbee;
7469     action = 0xdeadbee;
7470     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
7471     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7472     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
7473     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
7474
7475     state = 0xdeadbee;
7476     action = 0xdeadbee;
7477     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
7478     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7479     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
7480     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
7481
7482     state = 0xdeadbee;
7483     action = 0xdeadbee;
7484     r = MsiGetComponentState(hpkg, "leo", &state, &action);
7485     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7486     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
7487     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
7488
7489     state = 0xdeadbee;
7490     action = 0xdeadbee;
7491     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
7492     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7493     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
7494     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
7495
7496     state = 0xdeadbee;
7497     action = 0xdeadbee;
7498     r = MsiGetComponentState(hpkg, "libra", &state, &action);
7499     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7500     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
7501     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
7502
7503     state = 0xdeadbee;
7504     action = 0xdeadbee;
7505     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
7506     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7507     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
7508     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
7509
7510     state = 0xdeadbee;
7511     action = 0xdeadbee;
7512     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
7513     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7514     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
7515     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
7516
7517     state = 0xdeadbee;
7518     action = 0xdeadbee;
7519     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
7520     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7521     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
7522     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
7523
7524     state = 0xdeadbee;
7525     action = 0xdeadbee;
7526     r = MsiGetComponentState(hpkg, "canis", &state, &action);
7527     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7528     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
7529     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
7530
7531     state = 0xdeadbee;
7532     action = 0xdeadbee;
7533     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
7534     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7535     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
7536     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
7537
7538     state = 0xdeadbee;
7539     action = 0xdeadbee;
7540     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
7541     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7542     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
7543     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
7544
7545     state = 0xdeadbee;
7546     action = 0xdeadbee;
7547     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
7548     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7549     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
7550     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
7551
7552     state = 0xdeadbee;
7553     action = 0xdeadbee;
7554     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
7555     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
7556     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
7557     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
7558     
7559     MsiCloseHandle(hpkg);
7560     DeleteFileA(msifile);
7561 }
7562
7563 static void test_installprops(void)
7564 {
7565     MSIHANDLE hpkg, hdb;
7566     CHAR path[MAX_PATH];
7567     CHAR buf[MAX_PATH];
7568     DWORD size, type;
7569     LANGID langid;
7570     HKEY hkey1, hkey2;
7571     int res;
7572     UINT r;
7573
7574     GetCurrentDirectory(MAX_PATH, path);
7575     lstrcat(path, "\\");
7576     lstrcat(path, msifile);
7577
7578     hdb = create_package_db();
7579     ok( hdb, "failed to create database\n");
7580
7581     hpkg = package_from_db(hdb);
7582     ok( hpkg, "failed to create package\n");
7583
7584     MsiCloseHandle(hdb);
7585
7586     size = MAX_PATH;
7587     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
7588     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7589     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
7590
7591     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
7592
7593     RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
7594
7595     size = MAX_PATH;
7596     type = REG_SZ;
7597     *path = '\0';
7598     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
7599     {
7600         size = MAX_PATH;
7601         type = REG_SZ;
7602         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
7603     }
7604
7605     /* win9x doesn't set this */
7606     if (*path)
7607     {
7608         size = MAX_PATH;
7609         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
7610         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7611         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
7612     }
7613
7614     size = MAX_PATH;
7615     type = REG_SZ;
7616     *path = '\0';
7617     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
7618     {
7619         size = MAX_PATH;
7620         type = REG_SZ;
7621         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
7622     }
7623
7624     if (*path)
7625     {
7626         size = MAX_PATH;
7627         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
7628         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7629         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
7630     }
7631
7632     size = MAX_PATH;
7633     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
7634     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7635     trace("VersionDatabase = %s\n", buf);
7636
7637     size = MAX_PATH;
7638     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
7639     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7640     trace("VersionMsi = %s\n", buf);
7641
7642     size = MAX_PATH;
7643     r = MsiGetProperty(hpkg, "Date", buf, &size);
7644     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7645     trace("Date = %s\n", buf);
7646
7647     size = MAX_PATH;
7648     r = MsiGetProperty(hpkg, "Time", buf, &size);
7649     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7650     trace("Time = %s\n", buf);
7651
7652     size = MAX_PATH;
7653     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
7654     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
7655     trace("PackageCode = %s\n", buf);
7656
7657     langid = GetUserDefaultLangID();
7658     sprintf(path, "%d", langid);
7659
7660     size = MAX_PATH;
7661     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
7662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
7663     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
7664
7665     res = GetSystemMetrics(SM_CXSCREEN);
7666     size = MAX_PATH;
7667     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
7668     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
7669
7670     res = GetSystemMetrics(SM_CYSCREEN);
7671     size = MAX_PATH;
7672     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
7673     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
7674
7675     CloseHandle(hkey1);
7676     CloseHandle(hkey2);
7677     MsiCloseHandle(hpkg);
7678     DeleteFile(msifile);
7679 }
7680
7681 static void test_launchconditions(void)
7682 {
7683     MSIHANDLE hpkg;
7684     MSIHANDLE hdb;
7685     UINT r;
7686
7687     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7688
7689     hdb = create_package_db();
7690     ok( hdb, "failed to create package database\n" );
7691
7692     r = create_launchcondition_table( hdb );
7693     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
7694
7695     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
7696     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
7697
7698     /* invalid condition */
7699     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
7700     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
7701
7702     hpkg = package_from_db( hdb );
7703     ok( hpkg, "failed to create package\n");
7704
7705     MsiCloseHandle( hdb );
7706
7707     r = MsiSetProperty( hpkg, "X", "1" );
7708     ok( r == ERROR_SUCCESS, "failed to set property\n" );
7709
7710     /* invalid conditions are ignored */
7711     r = MsiDoAction( hpkg, "LaunchConditions" );
7712     ok( r == ERROR_SUCCESS, "cost init failed\n" );
7713
7714     /* verify LaunchConditions still does some verification */
7715     r = MsiSetProperty( hpkg, "X", "2" );
7716     ok( r == ERROR_SUCCESS, "failed to set property\n" );
7717
7718     r = MsiDoAction( hpkg, "LaunchConditions" );
7719     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
7720
7721     MsiCloseHandle( hpkg );
7722     DeleteFile( msifile );
7723 }
7724
7725 static void test_ccpsearch(void)
7726 {
7727     MSIHANDLE hdb, hpkg;
7728     CHAR prop[MAX_PATH];
7729     DWORD size = MAX_PATH;
7730     UINT r;
7731
7732     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7733
7734     hdb = create_package_db();
7735     ok(hdb, "failed to create package database\n");
7736
7737     r = create_ccpsearch_table(hdb);
7738     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7739
7740     r = add_ccpsearch_entry(hdb, "'CCP_random'");
7741     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7742
7743     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
7744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7745
7746     r = create_reglocator_table(hdb);
7747     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7748
7749     r = add_reglocator_entry(hdb, "'CCP_random', 0, 'htmlfile\\shell\\open\\nonexistent', '', 1");
7750     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7751
7752     r = create_drlocator_table(hdb);
7753     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7754
7755     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
7756     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7757
7758     r = create_signature_table(hdb);
7759     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7760
7761     hpkg = package_from_db(hdb);
7762     ok(hpkg, "failed to create package\n");
7763
7764     MsiCloseHandle(hdb);
7765
7766     r = MsiDoAction(hpkg, "CCPSearch");
7767     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7768
7769     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
7770     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7771     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
7772
7773     MsiCloseHandle(hpkg);
7774     DeleteFileA(msifile);
7775 }
7776
7777 static void test_complocator(void)
7778 {
7779     MSIHANDLE hdb, hpkg;
7780     UINT r;
7781     CHAR prop[MAX_PATH];
7782     CHAR expected[MAX_PATH];
7783     DWORD size = MAX_PATH;
7784
7785     hdb = create_package_db();
7786     ok(hdb, "failed to create package database\n");
7787
7788     r = create_appsearch_table(hdb);
7789     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7790
7791     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
7792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7793
7794     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
7795     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7796
7797     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
7798     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7799
7800     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
7801     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7802
7803     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
7804     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7805
7806     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
7807     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7808
7809     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
7810     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7811
7812     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
7813     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7814
7815     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
7816     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7817
7818     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
7819     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7820
7821     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
7822     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7823
7824     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
7825     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7826
7827     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
7828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7829
7830     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
7831     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7832
7833     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
7834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7835
7836     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
7837     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7838
7839     r = create_complocator_table(hdb);
7840     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7841
7842     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
7843     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7844
7845     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
7846     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7847
7848     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
7849     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7850
7851     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
7852     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7853
7854     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
7855     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7856
7857     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
7858     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7859
7860     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
7861     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7862
7863     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
7864     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7865
7866     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
7867     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7868
7869     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
7870     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7871
7872     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
7873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7874
7875     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
7876     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7877
7878     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
7879     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7880
7881     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
7882     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7883
7884     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
7885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7886
7887     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
7888     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7889
7890     r = create_signature_table(hdb);
7891     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7892
7893     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
7894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7895
7896     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
7897     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7898
7899     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
7900     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7901
7902     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
7903     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7904
7905     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
7906     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7907
7908     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
7909     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7910
7911     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
7912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7913
7914     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
7915     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7916
7917     hpkg = package_from_db(hdb);
7918     ok(hpkg, "failed to create package\n");
7919
7920     MsiCloseHandle(hdb);
7921
7922     create_test_file("abelisaurus");
7923     create_test_file("bactrosaurus");
7924     create_test_file("camelotia");
7925     create_test_file("diclonius");
7926     create_test_file("echinodon");
7927     create_test_file("falcarius");
7928     create_test_file("gallimimus");
7929     create_test_file("hagryphus");
7930     CreateDirectoryA("iguanodon", NULL);
7931     CreateDirectoryA("jobaria", NULL);
7932     CreateDirectoryA("kakuru", NULL);
7933     CreateDirectoryA("labocania", NULL);
7934     CreateDirectoryA("megaraptor", NULL);
7935     CreateDirectoryA("neosodon", NULL);
7936     CreateDirectoryA("olorotitan", NULL);
7937     CreateDirectoryA("pantydraco", NULL);
7938
7939     set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
7940                        "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
7941     set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
7942                        "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
7943     set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
7944                        "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
7945     set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
7946                        "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
7947     set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
7948                        "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
7949     set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
7950                        "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
7951     set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
7952                        "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
7953     set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
7954                        "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
7955
7956     r = MsiDoAction(hpkg, "AppSearch");
7957     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7958
7959     size = MAX_PATH;
7960     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
7961     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7962
7963     lstrcpyA(expected, CURR_DIR);
7964     lstrcatA(expected, "\\abelisaurus");
7965     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
7966        "Expected %s or empty string, got %s\n", expected, prop);
7967
7968     size = MAX_PATH;
7969     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
7970     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7971     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7972
7973     size = MAX_PATH;
7974     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
7975     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7976     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7977
7978     size = MAX_PATH;
7979     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
7980     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7981     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7982
7983     size = MAX_PATH;
7984     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
7985     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7986
7987     lstrcpyA(expected, CURR_DIR);
7988     lstrcatA(expected, "\\");
7989     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
7990        "Expected %s or empty string, got %s\n", expected, prop);
7991
7992     size = MAX_PATH;
7993     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
7994     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7995     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
7996
7997     size = MAX_PATH;
7998     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
7999     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8000     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8001
8002     size = MAX_PATH;
8003     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
8004     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8005     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8006
8007     size = MAX_PATH;
8008     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
8009     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8010     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8011
8012     size = MAX_PATH;
8013     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
8014     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8015     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8016
8017     size = MAX_PATH;
8018     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
8019     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8020     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8021
8022     size = MAX_PATH;
8023     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
8024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8025     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8026
8027     size = MAX_PATH;
8028     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
8029     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8030
8031     lstrcpyA(expected, CURR_DIR);
8032     lstrcatA(expected, "\\");
8033     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
8034        "Expected %s or empty string, got %s\n", expected, prop);
8035
8036     size = MAX_PATH;
8037     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
8038     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8039
8040     lstrcpyA(expected, CURR_DIR);
8041     lstrcatA(expected, "\\neosodon\\");
8042     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
8043        "Expected %s or empty string, got %s\n", expected, prop);
8044
8045     size = MAX_PATH;
8046     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
8047     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8048     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8049
8050     size = MAX_PATH;
8051     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
8052     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8053     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
8054
8055     MsiCloseHandle(hpkg);
8056     DeleteFileA("abelisaurus");
8057     DeleteFileA("bactrosaurus");
8058     DeleteFileA("camelotia");
8059     DeleteFileA("diclonius");
8060     DeleteFileA("echinodon");
8061     DeleteFileA("falcarius");
8062     DeleteFileA("gallimimus");
8063     DeleteFileA("hagryphus");
8064     RemoveDirectoryA("iguanodon");
8065     RemoveDirectoryA("jobaria");
8066     RemoveDirectoryA("kakuru");
8067     RemoveDirectoryA("labocania");
8068     RemoveDirectoryA("megaraptor");
8069     RemoveDirectoryA("neosodon");
8070     RemoveDirectoryA("olorotitan");
8071     RemoveDirectoryA("pantydraco");
8072     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
8073                           MSIINSTALLCONTEXT_MACHINE, NULL);
8074     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
8075                           MSIINSTALLCONTEXT_MACHINE, NULL);
8076     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
8077                           MSIINSTALLCONTEXT_MACHINE, NULL);
8078     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
8079                           MSIINSTALLCONTEXT_MACHINE, NULL);
8080     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
8081                           MSIINSTALLCONTEXT_MACHINE, NULL);
8082     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
8083                           MSIINSTALLCONTEXT_MACHINE, NULL);
8084     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
8085                           MSIINSTALLCONTEXT_MACHINE, NULL);
8086     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
8087                           MSIINSTALLCONTEXT_MACHINE, NULL);
8088     DeleteFileA(msifile);
8089 }
8090
8091 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
8092 {
8093     MSIHANDLE summary;
8094     UINT r;
8095
8096     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
8097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8098
8099     r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
8100     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8101
8102     r = MsiSummaryInfoPersist(summary);
8103     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8104
8105     MsiCloseHandle(summary);
8106 }
8107
8108 static void test_MsiGetSourcePath(void)
8109 {
8110     MSIHANDLE hdb, hpkg;
8111     CHAR path[MAX_PATH];
8112     CHAR cwd[MAX_PATH];
8113     CHAR subsrc[MAX_PATH];
8114     CHAR sub2[MAX_PATH];
8115     DWORD size;
8116     UINT r;
8117
8118     lstrcpyA(cwd, CURR_DIR);
8119     lstrcatA(cwd, "\\");
8120
8121     lstrcpyA(subsrc, cwd);
8122     lstrcatA(subsrc, "subsource");
8123     lstrcatA(subsrc, "\\");
8124
8125     lstrcpyA(sub2, subsrc);
8126     lstrcatA(sub2, "sub2");
8127     lstrcatA(sub2, "\\");
8128
8129     /* uncompressed source */
8130
8131     hdb = create_package_db();
8132     ok( hdb, "failed to create database\n");
8133
8134     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
8135
8136     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
8137     ok(r == S_OK, "failed\n");
8138
8139     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
8140     ok(r == S_OK, "failed\n");
8141
8142     r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
8143     ok(r == S_OK, "failed\n");
8144
8145     r = MsiDatabaseCommit(hdb);
8146     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
8147
8148     hpkg = package_from_db(hdb);
8149     ok(hpkg, "failed to create package\n");
8150
8151     MsiCloseHandle(hdb);
8152
8153     /* invalid database handle */
8154     size = MAX_PATH;
8155     lstrcpyA(path, "kiwi");
8156     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
8157     ok(r == ERROR_INVALID_HANDLE,
8158        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8159     ok(!lstrcmpA(path, "kiwi"),
8160        "Expected path to be unchanged, got \"%s\"\n", path);
8161     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8162
8163     /* NULL szFolder */
8164     size = MAX_PATH;
8165     lstrcpyA(path, "kiwi");
8166     r = MsiGetSourcePath(hpkg, NULL, path, &size);
8167     ok(r == ERROR_INVALID_PARAMETER,
8168        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8169     ok(!lstrcmpA(path, "kiwi"),
8170        "Expected path to be unchanged, got \"%s\"\n", path);
8171     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8172
8173     /* empty szFolder */
8174     size = MAX_PATH;
8175     lstrcpyA(path, "kiwi");
8176     r = MsiGetSourcePath(hpkg, "", path, &size);
8177     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8178     ok(!lstrcmpA(path, "kiwi"),
8179        "Expected path to be unchanged, got \"%s\"\n", path);
8180     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8181
8182     /* try TARGETDIR */
8183     size = MAX_PATH;
8184     lstrcpyA(path, "kiwi");
8185     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8186     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8187     ok(!lstrcmpA(path, "kiwi"),
8188        "Expected path to be unchanged, got \"%s\"\n", path);
8189     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8190
8191     /* try SourceDir */
8192     size = MAX_PATH;
8193     lstrcpyA(path, "kiwi");
8194     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8195     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8196     ok(!lstrcmpA(path, "kiwi"),
8197        "Expected path to be unchanged, got \"%s\"\n", path);
8198     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8199
8200     /* try SOURCEDIR */
8201     size = MAX_PATH;
8202     lstrcpyA(path, "kiwi");
8203     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8204     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8205     ok(!lstrcmpA(path, "kiwi"),
8206        "Expected path to be unchanged, got \"%s\"\n", path);
8207     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8208
8209     /* source path does not exist, but the property exists */
8210     size = MAX_PATH;
8211     lstrcpyA(path, "kiwi");
8212     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8214     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8215     ok(size == 0, "Expected 0, got %d\n", size);
8216
8217     /* try SubDir */
8218     size = MAX_PATH;
8219     lstrcpyA(path, "kiwi");
8220     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8221     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8222     ok(!lstrcmpA(path, "kiwi"),
8223        "Expected path to be unchanged, got \"%s\"\n", path);
8224     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8225
8226     /* try SubDir2 */
8227     size = MAX_PATH;
8228     lstrcpyA(path, "kiwi");
8229     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8230     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8231     ok(!lstrcmpA(path, "kiwi"),
8232        "Expected path to be unchanged, got \"%s\"\n", path);
8233     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8234
8235     r = MsiDoAction(hpkg, "CostInitialize");
8236     ok(r == ERROR_SUCCESS, "cost init failed\n");
8237
8238     /* try TARGETDIR after CostInitialize */
8239     size = MAX_PATH;
8240     lstrcpyA(path, "kiwi");
8241     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8242     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8243     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8244     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8245
8246     /* try SourceDir after CostInitialize */
8247     size = MAX_PATH;
8248     lstrcpyA(path, "kiwi");
8249     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8250     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8251     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8252     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8253
8254     /* try SOURCEDIR after CostInitialize */
8255     size = MAX_PATH;
8256     lstrcpyA(path, "kiwi");
8257     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8258     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8259     ok(!lstrcmpA(path, "kiwi"),
8260        "Expected path to be unchanged, got \"%s\"\n", path);
8261     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8262
8263     /* source path does not exist, but the property exists */
8264     size = MAX_PATH;
8265     lstrcpyA(path, "kiwi");
8266     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8267     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8268     todo_wine
8269     {
8270         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8271         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8272     }
8273
8274     /* try SubDir after CostInitialize */
8275     size = MAX_PATH;
8276     lstrcpyA(path, "kiwi");
8277     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8278     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8279     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8280     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8281
8282     /* try SubDir2 after CostInitialize */
8283     size = MAX_PATH;
8284     lstrcpyA(path, "kiwi");
8285     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8286     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8287     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8288     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8289
8290     r = MsiDoAction(hpkg, "ResolveSource");
8291     ok(r == ERROR_SUCCESS, "file cost failed\n");
8292
8293     /* try TARGETDIR after ResolveSource */
8294     size = MAX_PATH;
8295     lstrcpyA(path, "kiwi");
8296     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8297     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8298     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8299     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8300
8301     /* try SourceDir after ResolveSource */
8302     size = MAX_PATH;
8303     lstrcpyA(path, "kiwi");
8304     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8305     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8306     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8307     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8308
8309     /* try SOURCEDIR after ResolveSource */
8310     size = MAX_PATH;
8311     lstrcpyA(path, "kiwi");
8312     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8313     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8314     ok(!lstrcmpA(path, "kiwi"),
8315        "Expected path to be unchanged, got \"%s\"\n", path);
8316     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8317
8318     /* source path does not exist, but the property exists */
8319     size = MAX_PATH;
8320     lstrcpyA(path, "kiwi");
8321     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8322     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8323     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8324     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8325
8326     /* try SubDir after ResolveSource */
8327     size = MAX_PATH;
8328     lstrcpyA(path, "kiwi");
8329     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8330     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8331     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8332     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8333
8334     /* try SubDir2 after ResolveSource */
8335     size = MAX_PATH;
8336     lstrcpyA(path, "kiwi");
8337     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8338     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8339     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8340     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8341
8342     r = MsiDoAction(hpkg, "FileCost");
8343     ok(r == ERROR_SUCCESS, "file cost failed\n");
8344
8345     /* try TARGETDIR after FileCost */
8346     size = MAX_PATH;
8347     lstrcpyA(path, "kiwi");
8348     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8349     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8350     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8351     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8352
8353     /* try SourceDir after FileCost */
8354     size = MAX_PATH;
8355     lstrcpyA(path, "kiwi");
8356     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8357     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8358     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8359     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8360
8361     /* try SOURCEDIR after FileCost */
8362     size = MAX_PATH;
8363     lstrcpyA(path, "kiwi");
8364     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8365     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8366     ok(!lstrcmpA(path, "kiwi"),
8367        "Expected path to be unchanged, got \"%s\"\n", path);
8368     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8369
8370     /* try SubDir after FileCost */
8371     size = MAX_PATH;
8372     lstrcpyA(path, "kiwi");
8373     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8374     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8375     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8376     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8377
8378     /* try SubDir2 after FileCost */
8379     size = MAX_PATH;
8380     lstrcpyA(path, "kiwi");
8381     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8382     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8383     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8384     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8385
8386     r = MsiDoAction(hpkg, "CostFinalize");
8387     ok(r == ERROR_SUCCESS, "file cost failed\n");
8388
8389     /* try TARGETDIR after CostFinalize */
8390     size = MAX_PATH;
8391     lstrcpyA(path, "kiwi");
8392     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8393     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8394     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8395     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8396
8397     /* try SourceDir after CostFinalize */
8398     size = MAX_PATH;
8399     lstrcpyA(path, "kiwi");
8400     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8401     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8402     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8403     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8404
8405     /* try SOURCEDIR after CostFinalize */
8406     size = MAX_PATH;
8407     lstrcpyA(path, "kiwi");
8408     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8409     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8410     ok(!lstrcmpA(path, "kiwi"),
8411        "Expected path to be unchanged, got \"%s\"\n", path);
8412     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8413
8414     /* try SubDir after CostFinalize */
8415     size = MAX_PATH;
8416     lstrcpyA(path, "kiwi");
8417     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8418     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8419     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8420     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8421
8422     /* try SubDir2 after CostFinalize */
8423     size = MAX_PATH;
8424     lstrcpyA(path, "kiwi");
8425     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8426     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8427     ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
8428     ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
8429
8430     /* nonexistent directory */
8431     size = MAX_PATH;
8432     lstrcpyA(path, "kiwi");
8433     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
8434     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8435     ok(!lstrcmpA(path, "kiwi"),
8436        "Expected path to be unchanged, got \"%s\"\n", path);
8437     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8438
8439     /* NULL szPathBuf */
8440     size = MAX_PATH;
8441     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
8442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8443     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8444
8445     /* NULL pcchPathBuf */
8446     lstrcpyA(path, "kiwi");
8447     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
8448     ok(r == ERROR_INVALID_PARAMETER,
8449        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8450     ok(!lstrcmpA(path, "kiwi"),
8451        "Expected path to be unchanged, got \"%s\"\n", path);
8452
8453     /* pcchPathBuf is 0 */
8454     size = 0;
8455     lstrcpyA(path, "kiwi");
8456     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8457     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8458     ok(!lstrcmpA(path, "kiwi"),
8459        "Expected path to be unchanged, got \"%s\"\n", path);
8460     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8461
8462     /* pcchPathBuf does not have room for NULL terminator */
8463     size = lstrlenA(cwd);
8464     lstrcpyA(path, "kiwi");
8465     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8466     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8467     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
8468        "Expected path with no backslash, got \"%s\"\n", path);
8469     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8470
8471     /* pcchPathBuf has room for NULL terminator */
8472     size = lstrlenA(cwd) + 1;
8473     lstrcpyA(path, "kiwi");
8474     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8475     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8476     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8477     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8478
8479     MsiCloseHandle(hpkg);
8480
8481     /* compressed source */
8482
8483     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
8484     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8485
8486     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
8487
8488     hpkg = package_from_db(hdb);
8489     ok(hpkg, "failed to create package\n");
8490
8491     r = MsiDoAction(hpkg, "CostInitialize");
8492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8493     r = MsiDoAction(hpkg, "FileCost");
8494     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8495     r = MsiDoAction(hpkg, "CostFinalize");
8496     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8497
8498     /* try TARGETDIR after CostFinalize */
8499     size = MAX_PATH;
8500     lstrcpyA(path, "kiwi");
8501     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
8502     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8503     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8504     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8505
8506     /* try SourceDir after CostFinalize */
8507     size = MAX_PATH;
8508     lstrcpyA(path, "kiwi");
8509     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
8510     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8511     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8512     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8513
8514     /* try SOURCEDIR after CostFinalize */
8515     size = MAX_PATH;
8516     lstrcpyA(path, "kiwi");
8517     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
8518     todo_wine
8519     {
8520         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8521         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8522         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8523     }
8524
8525     /* try SubDir after CostFinalize */
8526     size = MAX_PATH;
8527     lstrcpyA(path, "kiwi");
8528     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8529     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8530     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8531     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8532
8533     /* try SubDir2 after CostFinalize */
8534     size = MAX_PATH;
8535     lstrcpyA(path, "kiwi");
8536     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8538     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8539     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8540
8541     MsiCloseHandle(hpkg);
8542     DeleteFile(msifile);
8543 }
8544
8545 static void test_shortlongsource(void)
8546 {
8547     MSIHANDLE hdb, hpkg;
8548     CHAR path[MAX_PATH];
8549     CHAR cwd[MAX_PATH];
8550     CHAR subsrc[MAX_PATH];
8551     DWORD size;
8552     UINT r;
8553
8554     lstrcpyA(cwd, CURR_DIR);
8555     lstrcatA(cwd, "\\");
8556
8557     lstrcpyA(subsrc, cwd);
8558     lstrcatA(subsrc, "long");
8559     lstrcatA(subsrc, "\\");
8560
8561     /* long file names */
8562
8563     hdb = create_package_db();
8564     ok( hdb, "failed to create database\n");
8565
8566     set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
8567
8568     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
8569     ok(r == S_OK, "failed\n");
8570
8571     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
8572     ok(r == S_OK, "failed\n");
8573
8574     /* CostInitialize:short */
8575     r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
8576     ok(r == S_OK, "failed\n");
8577
8578     /* CostInitialize:long */
8579     r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
8580     ok(r == S_OK, "failed\n");
8581
8582     /* FileCost:short */
8583     r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
8584     ok(r == S_OK, "failed\n");
8585
8586     /* FileCost:long */
8587     r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
8588     ok(r == S_OK, "failed\n");
8589
8590     /* CostFinalize:short */
8591     r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
8592     ok(r == S_OK, "failed\n");
8593
8594     /* CostFinalize:long */
8595     r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
8596     ok(r == S_OK, "failed\n");
8597
8598     MsiDatabaseCommit(hdb);
8599
8600     hpkg = package_from_db(hdb);
8601     ok(hpkg, "failed to create package\n");
8602
8603     MsiCloseHandle(hdb);
8604
8605     CreateDirectoryA("one", NULL);
8606     CreateDirectoryA("four", NULL);
8607
8608     r = MsiDoAction(hpkg, "CostInitialize");
8609     ok(r == ERROR_SUCCESS, "file cost failed\n");
8610
8611     CreateDirectory("five", NULL);
8612     CreateDirectory("eight", NULL);
8613
8614     r = MsiDoAction(hpkg, "FileCost");
8615     ok(r == ERROR_SUCCESS, "file cost failed\n");
8616
8617     CreateDirectory("nine", NULL);
8618     CreateDirectory("twelve", NULL);
8619
8620     r = MsiDoAction(hpkg, "CostFinalize");
8621     ok(r == ERROR_SUCCESS, "file cost failed\n");
8622
8623     /* neither short nor long source directories exist */
8624     size = MAX_PATH;
8625     lstrcpyA(path, "kiwi");
8626     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8627     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8628     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8629     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8630
8631     CreateDirectoryA("short", NULL);
8632
8633     /* short source directory exists */
8634     size = MAX_PATH;
8635     lstrcpyA(path, "kiwi");
8636     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8637     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8638     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8639     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8640
8641     CreateDirectoryA("long", NULL);
8642
8643     /* both short and long source directories exist */
8644     size = MAX_PATH;
8645     lstrcpyA(path, "kiwi");
8646     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8647     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8648     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8649     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8650
8651     lstrcpyA(subsrc, cwd);
8652     lstrcatA(subsrc, "two");
8653     lstrcatA(subsrc, "\\");
8654
8655     /* short dir exists before CostInitialize */
8656     size = MAX_PATH;
8657     lstrcpyA(path, "kiwi");
8658     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8659     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8660     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8661     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8662
8663     lstrcpyA(subsrc, cwd);
8664     lstrcatA(subsrc, "four");
8665     lstrcatA(subsrc, "\\");
8666
8667     /* long dir exists before CostInitialize */
8668     size = MAX_PATH;
8669     lstrcpyA(path, "kiwi");
8670     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
8671     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8672     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8673     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8674
8675     lstrcpyA(subsrc, cwd);
8676     lstrcatA(subsrc, "six");
8677     lstrcatA(subsrc, "\\");
8678
8679     /* short dir exists before FileCost */
8680     size = MAX_PATH;
8681     lstrcpyA(path, "kiwi");
8682     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
8683     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8684     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8685     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8686
8687     lstrcpyA(subsrc, cwd);
8688     lstrcatA(subsrc, "eight");
8689     lstrcatA(subsrc, "\\");
8690
8691     /* long dir exists before FileCost */
8692     size = MAX_PATH;
8693     lstrcpyA(path, "kiwi");
8694     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
8695     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8696     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8697     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8698
8699     lstrcpyA(subsrc, cwd);
8700     lstrcatA(subsrc, "ten");
8701     lstrcatA(subsrc, "\\");
8702
8703     /* short dir exists before CostFinalize */
8704     size = MAX_PATH;
8705     lstrcpyA(path, "kiwi");
8706     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
8707     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8708     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8709     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8710
8711     lstrcpyA(subsrc, cwd);
8712     lstrcatA(subsrc, "twelve");
8713     lstrcatA(subsrc, "\\");
8714
8715     /* long dir exists before CostFinalize */
8716     size = MAX_PATH;
8717     lstrcpyA(path, "kiwi");
8718     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
8719     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8720     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8721     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8722
8723     MsiCloseHandle(hpkg);
8724     RemoveDirectoryA("short");
8725     RemoveDirectoryA("long");
8726     RemoveDirectoryA("one");
8727     RemoveDirectoryA("four");
8728     RemoveDirectoryA("five");
8729     RemoveDirectoryA("eight");
8730     RemoveDirectoryA("nine");
8731     RemoveDirectoryA("twelve");
8732
8733     /* short file names */
8734
8735     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
8736     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8737
8738     set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
8739
8740     hpkg = package_from_db(hdb);
8741     ok(hpkg, "failed to create package\n");
8742
8743     MsiCloseHandle(hdb);
8744
8745     CreateDirectoryA("one", NULL);
8746     CreateDirectoryA("four", NULL);
8747
8748     r = MsiDoAction(hpkg, "CostInitialize");
8749     ok(r == ERROR_SUCCESS, "file cost failed\n");
8750
8751     CreateDirectory("five", NULL);
8752     CreateDirectory("eight", NULL);
8753
8754     r = MsiDoAction(hpkg, "FileCost");
8755     ok(r == ERROR_SUCCESS, "file cost failed\n");
8756
8757     CreateDirectory("nine", NULL);
8758     CreateDirectory("twelve", NULL);
8759
8760     r = MsiDoAction(hpkg, "CostFinalize");
8761     ok(r == ERROR_SUCCESS, "file cost failed\n");
8762
8763     lstrcpyA(subsrc, cwd);
8764     lstrcatA(subsrc, "short");
8765     lstrcatA(subsrc, "\\");
8766
8767     /* neither short nor long source directories exist */
8768     size = MAX_PATH;
8769     lstrcpyA(path, "kiwi");
8770     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8771     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8772     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8773     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8774
8775     CreateDirectoryA("short", NULL);
8776
8777     /* short source directory exists */
8778     size = MAX_PATH;
8779     lstrcpyA(path, "kiwi");
8780     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8781     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8782     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8783     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8784
8785     CreateDirectoryA("long", NULL);
8786
8787     /* both short and long source directories exist */
8788     size = MAX_PATH;
8789     lstrcpyA(path, "kiwi");
8790     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
8791     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8792     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8793     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8794
8795     lstrcpyA(subsrc, cwd);
8796     lstrcatA(subsrc, "one");
8797     lstrcatA(subsrc, "\\");
8798
8799     /* short dir exists before CostInitialize */
8800     size = MAX_PATH;
8801     lstrcpyA(path, "kiwi");
8802     r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
8803     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8804     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8805     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8806
8807     lstrcpyA(subsrc, cwd);
8808     lstrcatA(subsrc, "three");
8809     lstrcatA(subsrc, "\\");
8810
8811     /* long dir exists before CostInitialize */
8812     size = MAX_PATH;
8813     lstrcpyA(path, "kiwi");
8814     r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
8815     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8816     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8817     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8818
8819     lstrcpyA(subsrc, cwd);
8820     lstrcatA(subsrc, "five");
8821     lstrcatA(subsrc, "\\");
8822
8823     /* short dir exists before FileCost */
8824     size = MAX_PATH;
8825     lstrcpyA(path, "kiwi");
8826     r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
8827     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8828     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8829     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8830
8831     lstrcpyA(subsrc, cwd);
8832     lstrcatA(subsrc, "seven");
8833     lstrcatA(subsrc, "\\");
8834
8835     /* long dir exists before FileCost */
8836     size = MAX_PATH;
8837     lstrcpyA(path, "kiwi");
8838     r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
8839     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8840     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8841     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8842
8843     lstrcpyA(subsrc, cwd);
8844     lstrcatA(subsrc, "nine");
8845     lstrcatA(subsrc, "\\");
8846
8847     /* short dir exists before CostFinalize */
8848     size = MAX_PATH;
8849     lstrcpyA(path, "kiwi");
8850     r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
8851     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8852     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8853     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8854
8855     lstrcpyA(subsrc, cwd);
8856     lstrcatA(subsrc, "eleven");
8857     lstrcatA(subsrc, "\\");
8858
8859     /* long dir exists before CostFinalize */
8860     size = MAX_PATH;
8861     lstrcpyA(path, "kiwi");
8862     r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
8863     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8864     ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
8865     ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
8866
8867     MsiCloseHandle(hpkg);
8868     RemoveDirectoryA("short");
8869     RemoveDirectoryA("long");
8870     RemoveDirectoryA("one");
8871     RemoveDirectoryA("four");
8872     RemoveDirectoryA("five");
8873     RemoveDirectoryA("eight");
8874     RemoveDirectoryA("nine");
8875     RemoveDirectoryA("twelve");
8876     DeleteFileA(msifile);
8877 }
8878
8879 static void test_sourcedir(void)
8880 {
8881     MSIHANDLE hdb, hpkg;
8882     CHAR package[10];
8883     CHAR path[MAX_PATH];
8884     CHAR cwd[MAX_PATH];
8885     CHAR subsrc[MAX_PATH];
8886     DWORD size;
8887     UINT r;
8888
8889     lstrcpyA(cwd, CURR_DIR);
8890     lstrcatA(cwd, "\\");
8891
8892     lstrcpyA(subsrc, cwd);
8893     lstrcatA(subsrc, "long");
8894     lstrcatA(subsrc, "\\");
8895
8896     hdb = create_package_db();
8897     ok( hdb, "failed to create database\n");
8898
8899     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
8900     ok(r == S_OK, "failed\n");
8901
8902     sprintf(package, "#%li", hdb);
8903     r = MsiOpenPackage(package, &hpkg);
8904     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8905
8906     /* properties only */
8907
8908     /* SourceDir prop */
8909     size = MAX_PATH;
8910     lstrcpyA(path, "kiwi");
8911     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8912     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8913     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8914     ok(size == 0, "Expected 0, got %d\n", size);
8915
8916     /* SOURCEDIR prop */
8917     size = MAX_PATH;
8918     lstrcpyA(path, "kiwi");
8919     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8920     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8921     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8922     ok(size == 0, "Expected 0, got %d\n", size);
8923
8924     r = MsiDoAction(hpkg, "CostInitialize");
8925     ok(r == ERROR_SUCCESS, "file cost failed\n");
8926
8927     /* SourceDir after CostInitialize */
8928     size = MAX_PATH;
8929     lstrcpyA(path, "kiwi");
8930     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8931     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8932     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8933     ok(size == 0, "Expected 0, got %d\n", size);
8934
8935     /* SOURCEDIR after CostInitialize */
8936     size = MAX_PATH;
8937     lstrcpyA(path, "kiwi");
8938     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8939     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8940     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8941     ok(size == 0, "Expected 0, got %d\n", size);
8942
8943     r = MsiDoAction(hpkg, "FileCost");
8944     ok(r == ERROR_SUCCESS, "file cost failed\n");
8945
8946     /* SourceDir after FileCost */
8947     size = MAX_PATH;
8948     lstrcpyA(path, "kiwi");
8949     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8950     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8951     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8952     ok(size == 0, "Expected 0, got %d\n", size);
8953
8954     /* SOURCEDIR after FileCost */
8955     size = MAX_PATH;
8956     lstrcpyA(path, "kiwi");
8957     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8958     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8959     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8960     ok(size == 0, "Expected 0, got %d\n", size);
8961
8962     r = MsiDoAction(hpkg, "CostFinalize");
8963     ok(r == ERROR_SUCCESS, "file cost failed\n");
8964
8965     /* SourceDir after CostFinalize */
8966     size = MAX_PATH;
8967     lstrcpyA(path, "kiwi");
8968     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8969     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8970     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8971     ok(size == 0, "Expected 0, got %d\n", size);
8972
8973     /* SOURCEDIR after CostFinalize */
8974     size = MAX_PATH;
8975     lstrcpyA(path, "kiwi");
8976     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8977     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8978     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
8979     ok(size == 0, "Expected 0, got %d\n", size);
8980
8981     r = MsiDoAction(hpkg, "ResolveSource");
8982     ok(r == ERROR_SUCCESS, "file cost failed\n");
8983
8984     /* SourceDir after ResolveSource */
8985     size = MAX_PATH;
8986     lstrcpyA(path, "kiwi");
8987     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
8988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8989     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8990     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8991
8992     /* SOURCEDIR after ResolveSource */
8993     size = MAX_PATH;
8994     lstrcpyA(path, "kiwi");
8995     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
8996     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8997     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8998     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8999
9000     /* random casing */
9001     size = MAX_PATH;
9002     lstrcpyA(path, "kiwi");
9003     r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
9004     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9005     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9006     ok(size == 0, "Expected 0, got %d\n", size);
9007
9008     MsiCloseHandle(hpkg);
9009
9010     /* reset the package state */
9011     sprintf(package, "#%li", hdb);
9012     r = MsiOpenPackage(package, &hpkg);
9013     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9014
9015     /* test how MsiGetSourcePath affects the properties */
9016
9017     /* SourceDir prop */
9018     size = MAX_PATH;
9019     lstrcpyA(path, "kiwi");
9020     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9021     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9022     todo_wine
9023     {
9024         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9025         ok(size == 0, "Expected 0, got %d\n", size);
9026     }
9027
9028     size = MAX_PATH;
9029     lstrcpyA(path, "kiwi");
9030     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
9031     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9032     ok(!lstrcmpA(path, "kiwi"),
9033        "Expected path to be unchanged, got \"%s\"\n", path);
9034     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9035
9036     /* SourceDir after MsiGetSourcePath */
9037     size = MAX_PATH;
9038     lstrcpyA(path, "kiwi");
9039     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9040     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9041     todo_wine
9042     {
9043         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9044         ok(size == 0, "Expected 0, got %d\n", size);
9045     }
9046
9047     /* SOURCEDIR prop */
9048     size = MAX_PATH;
9049     lstrcpyA(path, "kiwi");
9050     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9052     todo_wine
9053     {
9054         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9055         ok(size == 0, "Expected 0, got %d\n", size);
9056     }
9057
9058     size = MAX_PATH;
9059     lstrcpyA(path, "kiwi");
9060     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9061     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9062     ok(!lstrcmpA(path, "kiwi"),
9063        "Expected path to be unchanged, got \"%s\"\n", path);
9064     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9065
9066     /* SOURCEDIR prop after MsiGetSourcePath */
9067     size = MAX_PATH;
9068     lstrcpyA(path, "kiwi");
9069     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9070     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9071     todo_wine
9072     {
9073         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9074         ok(size == 0, "Expected 0, got %d\n", size);
9075     }
9076
9077     r = MsiDoAction(hpkg, "CostInitialize");
9078     ok(r == ERROR_SUCCESS, "file cost failed\n");
9079
9080     /* SourceDir after CostInitialize */
9081     size = MAX_PATH;
9082     lstrcpyA(path, "kiwi");
9083     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9085     todo_wine
9086     {
9087         ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
9088         ok(size == 0, "Expected 0, got %d\n", size);
9089     }
9090
9091     size = MAX_PATH;
9092     lstrcpyA(path, "kiwi");
9093     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
9094     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9095     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9096     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9097
9098     /* SourceDir after MsiGetSourcePath */
9099     size = MAX_PATH;
9100     lstrcpyA(path, "kiwi");
9101     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9102     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9103     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9104     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9105
9106     /* SOURCEDIR after CostInitialize */
9107     size = MAX_PATH;
9108     lstrcpyA(path, "kiwi");
9109     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9110     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9111     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9112     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9113
9114     /* SOURCEDIR source path still does not exist */
9115     size = MAX_PATH;
9116     lstrcpyA(path, "kiwi");
9117     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9118     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9119     ok(!lstrcmpA(path, "kiwi"),
9120        "Expected path to be unchanged, got \"%s\"\n", path);
9121     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9122
9123     r = MsiDoAction(hpkg, "FileCost");
9124     ok(r == ERROR_SUCCESS, "file cost failed\n");
9125
9126     /* SourceDir after FileCost */
9127     size = MAX_PATH;
9128     lstrcpyA(path, "kiwi");
9129     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9130     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9131     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9132     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9133
9134     /* SOURCEDIR after FileCost */
9135     size = MAX_PATH;
9136     lstrcpyA(path, "kiwi");
9137     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9138     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9139     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9140     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9141
9142     /* SOURCEDIR source path still does not exist */
9143     size = MAX_PATH;
9144     lstrcpyA(path, "kiwi");
9145     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9146     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9147     ok(!lstrcmpA(path, "kiwi"),
9148        "Expected path to be unchanged, got \"%s\"\n", path);
9149     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9150
9151     r = MsiDoAction(hpkg, "CostFinalize");
9152     ok(r == ERROR_SUCCESS, "file cost failed\n");
9153
9154     /* SourceDir after CostFinalize */
9155     size = MAX_PATH;
9156     lstrcpyA(path, "kiwi");
9157     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9158     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9159     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9160     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9161
9162     /* SOURCEDIR after CostFinalize */
9163     size = MAX_PATH;
9164     lstrcpyA(path, "kiwi");
9165     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9166     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9167     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9168     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9169
9170     /* SOURCEDIR source path still does not exist */
9171     size = MAX_PATH;
9172     lstrcpyA(path, "kiwi");
9173     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9174     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9175     ok(!lstrcmpA(path, "kiwi"),
9176        "Expected path to be unchanged, got \"%s\"\n", path);
9177     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9178
9179     r = MsiDoAction(hpkg, "ResolveSource");
9180     ok(r == ERROR_SUCCESS, "file cost failed\n");
9181
9182     /* SourceDir after ResolveSource */
9183     size = MAX_PATH;
9184     lstrcpyA(path, "kiwi");
9185     r = MsiGetProperty(hpkg, "SourceDir", path, &size);
9186     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9187     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9188     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9189
9190     /* SOURCEDIR after ResolveSource */
9191     size = MAX_PATH;
9192     lstrcpyA(path, "kiwi");
9193     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
9194     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9195     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
9196     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
9197
9198     /* SOURCEDIR source path still does not exist */
9199     size = MAX_PATH;
9200     lstrcpyA(path, "kiwi");
9201     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
9202     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
9203     ok(!lstrcmpA(path, "kiwi"),
9204        "Expected path to be unchanged, got \"%s\"\n", path);
9205     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9206
9207     MsiCloseHandle(hdb);
9208     MsiCloseHandle(hpkg);
9209     DeleteFileA(msifile);
9210 }
9211
9212 struct access_res
9213 {
9214     BOOL gothandle;
9215     DWORD lasterr;
9216     BOOL ignore;
9217 };
9218
9219 static const struct access_res create[16] =
9220 {
9221     { TRUE, ERROR_SUCCESS, TRUE },
9222     { TRUE, ERROR_SUCCESS, TRUE },
9223     { TRUE, ERROR_SUCCESS, FALSE },
9224     { TRUE, ERROR_SUCCESS, FALSE },
9225     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9226     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9227     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9228     { TRUE, ERROR_SUCCESS, FALSE },
9229     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9230     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9231     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9232     { TRUE, ERROR_SUCCESS, TRUE },
9233     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9234     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9235     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9236     { TRUE, ERROR_SUCCESS, TRUE }
9237 };
9238
9239 static const struct access_res create_commit[16] =
9240 {
9241     { TRUE, ERROR_SUCCESS, TRUE },
9242     { TRUE, ERROR_SUCCESS, TRUE },
9243     { TRUE, ERROR_SUCCESS, FALSE },
9244     { TRUE, ERROR_SUCCESS, FALSE },
9245     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9246     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9247     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9248     { TRUE, ERROR_SUCCESS, FALSE },
9249     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9250     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9251     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9252     { TRUE, ERROR_SUCCESS, TRUE },
9253     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9254     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9255     { FALSE, ERROR_SHARING_VIOLATION, FALSE },
9256     { TRUE, ERROR_SUCCESS, TRUE }
9257 };
9258
9259 static const struct access_res create_close[16] =
9260 {
9261     { TRUE, ERROR_SUCCESS, FALSE },
9262     { TRUE, ERROR_SUCCESS, FALSE },
9263     { TRUE, ERROR_SUCCESS, FALSE },
9264     { TRUE, ERROR_SUCCESS, FALSE },
9265     { TRUE, ERROR_SUCCESS, FALSE },
9266     { TRUE, ERROR_SUCCESS, FALSE },
9267     { TRUE, ERROR_SUCCESS, FALSE },
9268     { TRUE, ERROR_SUCCESS, FALSE },
9269     { TRUE, ERROR_SUCCESS, FALSE },
9270     { TRUE, ERROR_SUCCESS, FALSE },
9271     { TRUE, ERROR_SUCCESS, FALSE },
9272     { TRUE, ERROR_SUCCESS, FALSE },
9273     { TRUE, ERROR_SUCCESS, FALSE },
9274     { TRUE, ERROR_SUCCESS, FALSE },
9275     { TRUE, ERROR_SUCCESS, FALSE },
9276     { TRUE, ERROR_SUCCESS }
9277 };
9278
9279 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
9280 {
9281     DWORD access = 0, share = 0;
9282     DWORD lasterr;
9283     HANDLE hfile;
9284     int i, j, idx = 0;
9285
9286     for (i = 0; i < 4; i++)
9287     {
9288         if (i == 0) access = 0;
9289         if (i == 1) access = GENERIC_READ;
9290         if (i == 2) access = GENERIC_WRITE;
9291         if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
9292
9293         for (j = 0; j < 4; j++)
9294         {
9295             if (ares[idx].ignore)
9296                 continue;
9297
9298             if (j == 0) share = 0;
9299             if (j == 1) share = FILE_SHARE_READ;
9300             if (j == 2) share = FILE_SHARE_WRITE;
9301             if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
9302
9303             SetLastError(0xdeadbeef);
9304             hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
9305                                 FILE_ATTRIBUTE_NORMAL, 0);
9306             lasterr = GetLastError();
9307
9308             ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
9309                "(%d, handle, %d): Expected %d, got %d\n",
9310                line, idx, ares[idx].gothandle,
9311                (hfile != INVALID_HANDLE_VALUE));
9312
9313             ok(lasterr == ares[idx].lasterr ||
9314                lasterr == 0xdeadbeef, /* win9x */
9315                "(%d, lasterr, %d): Expected %d, got %d\n",
9316                line, idx, ares[idx].lasterr, lasterr);
9317
9318             CloseHandle(hfile);
9319             idx++;
9320         }
9321     }
9322 }
9323
9324 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
9325
9326 static void test_access(void)
9327 {
9328     MSIHANDLE hdb;
9329     UINT r;
9330
9331     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
9332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9333
9334     test_file_access(msifile, create);
9335
9336     r = MsiDatabaseCommit(hdb);
9337     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9338
9339     test_file_access(msifile, create_commit);
9340
9341     MsiCloseHandle(hdb);
9342
9343     test_file_access(msifile, create_close);
9344
9345     DeleteFileA(msifile);
9346
9347     r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
9348     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9349
9350     test_file_access(msifile, create);
9351
9352     r = MsiDatabaseCommit(hdb);
9353     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9354
9355     test_file_access(msifile, create_commit);
9356
9357     MsiCloseHandle(hdb);
9358
9359     test_file_access(msifile, create_close);
9360
9361     DeleteFileA(msifile);
9362 }
9363
9364 static void test_emptypackage(void)
9365 {
9366     MSIHANDLE hpkg, hdb, hsuminfo;
9367     MSIHANDLE hview, hrec;
9368     MSICONDITION condition;
9369     CHAR buffer[MAX_PATH];
9370     DWORD size;
9371     UINT r;
9372
9373     r = MsiOpenPackageA("", &hpkg);
9374     todo_wine
9375     {
9376         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9377     }
9378
9379     hdb = MsiGetActiveDatabase(hpkg);
9380     todo_wine
9381     {
9382         ok(hdb != 0, "Expected a valid database handle\n");
9383     }
9384
9385     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
9386     todo_wine
9387     {
9388         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9389     }
9390     r = MsiViewExecute(hview, 0);
9391     todo_wine
9392     {
9393         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9394     }
9395
9396     r = MsiViewFetch(hview, &hrec);
9397     todo_wine
9398     {
9399         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9400     }
9401
9402     size = MAX_PATH;
9403     r = MsiRecordGetString(hrec, 1, buffer, &size);
9404     todo_wine
9405     {
9406         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9407         ok(!lstrcmpA(buffer, "_Property"),
9408            "Expected \"_Property\", got \"%s\"\n", buffer);
9409     }
9410
9411     MsiCloseHandle(hrec);
9412
9413     r = MsiViewFetch(hview, &hrec);
9414     todo_wine
9415     {
9416         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9417     }
9418
9419     size = MAX_PATH;
9420     r = MsiRecordGetString(hrec, 1, buffer, &size);
9421     todo_wine
9422     {
9423         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9424         ok(!lstrcmpA(buffer, "#_FolderCache"),
9425            "Expected \"_Property\", got \"%s\"\n", buffer);
9426     }
9427
9428     MsiCloseHandle(hrec);
9429     MsiViewClose(hview);
9430     MsiCloseHandle(hview);
9431
9432     condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
9433     todo_wine
9434     {
9435         ok(condition == MSICONDITION_FALSE,
9436            "Expected MSICONDITION_FALSE, got %d\n", condition);
9437     }
9438
9439     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
9440     todo_wine
9441     {
9442         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9443     }
9444     r = MsiViewExecute(hview, 0);
9445     todo_wine
9446     {
9447         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9448     }
9449
9450     /* _Property table is not empty */
9451     r = MsiViewFetch(hview, &hrec);
9452     todo_wine
9453     {
9454         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9455     }
9456
9457     MsiCloseHandle(hrec);
9458     MsiViewClose(hview);
9459     MsiCloseHandle(hview);
9460
9461     condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
9462     todo_wine
9463     {
9464         ok(condition == MSICONDITION_FALSE,
9465            "Expected MSICONDITION_FALSE, got %d\n", condition);
9466     }
9467
9468     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
9469     todo_wine
9470     {
9471         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9472     }
9473     r = MsiViewExecute(hview, 0);
9474     todo_wine
9475     {
9476         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9477     }
9478
9479     /* #_FolderCache is not empty */
9480     r = MsiViewFetch(hview, &hrec);
9481     todo_wine
9482     {
9483         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9484     }
9485
9486     MsiCloseHandle(hrec);
9487     MsiViewClose(hview);
9488     MsiCloseHandle(hview);
9489
9490     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
9491     todo_wine
9492     {
9493         ok(r == ERROR_BAD_QUERY_SYNTAX,
9494            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
9495     }
9496
9497     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
9498     todo_wine
9499     {
9500         ok(r == ERROR_BAD_QUERY_SYNTAX,
9501            "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
9502     }
9503
9504     r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
9505     todo_wine
9506     {
9507         ok(r == ERROR_INSTALL_PACKAGE_INVALID,
9508            "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
9509     }
9510
9511     MsiCloseHandle(hsuminfo);
9512
9513     r = MsiDatabaseCommit(hdb);
9514     todo_wine
9515     {
9516         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9517     }
9518
9519     MsiCloseHandle(hdb);
9520     MsiCloseHandle(hpkg);
9521 }
9522
9523 START_TEST(package)
9524 {
9525     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
9526
9527     test_createpackage();
9528     test_doaction();
9529     test_gettargetpath_bad();
9530     test_settargetpath();
9531     test_props();
9532     test_property_table();
9533     test_condition();
9534     test_msipackage();
9535     test_formatrecord2();
9536     test_states();
9537     test_getproperty();
9538     test_removefiles();
9539     test_appsearch();
9540     test_appsearch_complocator();
9541     test_appsearch_reglocator();
9542     test_appsearch_inilocator();
9543     test_appsearch_drlocator();
9544     test_featureparents();
9545     test_installprops();
9546     test_launchconditions();
9547     test_ccpsearch();
9548     test_complocator();
9549     test_MsiGetSourcePath();
9550     test_shortlongsource();
9551     test_sourcedir();
9552     test_access();
9553     test_emptypackage();
9554 }