55d9bb35b8fff5e0ac56cce0320c396b81bef2ac
[reactos.git] / rostests / winetests / msi / package.c
1 /*
2 * tests for Microsoft Installer functionality
3 *
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #define COBJMACROS
23
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29 #include <srrestoreptapi.h>
30
31 #include "wine/test.h"
32
33 static const char msifile[] = "winetest.msi";
34 char CURR_DIR[MAX_PATH];
35
36 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
37
38 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
39
40 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
41 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
42
43 static void init_functionpointers(void)
44 {
45 HMODULE hmsi = GetModuleHandleA("msi.dll");
46 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
47 HMODULE hsrclient;
48
49 #define GET_PROC(mod, func) \
50 p ## func = (void*)GetProcAddress(mod, #func);
51
52 GET_PROC(hmsi, MsiApplyMultiplePatchesA);
53
54 GET_PROC(hadvapi32, ConvertSidToStringSidA);
55
56 hsrclient = LoadLibraryA("srclient.dll");
57 GET_PROC(hsrclient, SRRemoveRestorePoint);
58 GET_PROC(hsrclient, SRSetRestorePointA);
59 #undef GET_PROC
60 }
61
62
63 static LPSTR get_user_sid(LPSTR *usersid)
64 {
65 HANDLE token;
66 BYTE buf[1024];
67 DWORD size;
68 PTOKEN_USER user;
69
70 if (!pConvertSidToStringSidA)
71 {
72 win_skip("ConvertSidToStringSidA is not available\n");
73 return NULL;
74 }
75
76 *usersid = NULL;
77 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
78 size = sizeof(buf);
79 GetTokenInformation(token, TokenUser, buf, size, &size);
80 user = (PTOKEN_USER)buf;
81 pConvertSidToStringSidA(user->User.Sid, usersid);
82 ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
83 CloseHandle(token);
84 return *usersid;
85 }
86
87 /* RegDeleteTreeW from dlls/advapi32/registry.c */
88 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
89 {
90 LONG ret;
91 DWORD dwMaxSubkeyLen, dwMaxValueLen;
92 DWORD dwMaxLen, dwSize;
93 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
94 HKEY hSubKey = hKey;
95
96 if(lpszSubKey)
97 {
98 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
99 if (ret) return ret;
100 }
101
102 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
103 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
104 if (ret) goto cleanup;
105
106 dwMaxSubkeyLen++;
107 dwMaxValueLen++;
108 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
109 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
110 {
111 /* Name too big: alloc a buffer for it */
112 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
113 {
114 ret = ERROR_NOT_ENOUGH_MEMORY;
115 goto cleanup;
116 }
117 }
118
119 /* Recursively delete all the subkeys */
120 while (TRUE)
121 {
122 dwSize = dwMaxLen;
123 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
124 NULL, NULL, NULL)) break;
125
126 ret = package_RegDeleteTreeW(hSubKey, lpszName);
127 if (ret) goto cleanup;
128 }
129
130 if (lpszSubKey)
131 ret = RegDeleteKeyW(hKey, lpszSubKey);
132 else
133 while (TRUE)
134 {
135 dwSize = dwMaxLen;
136 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
137 NULL, NULL, NULL, NULL)) break;
138
139 ret = RegDeleteValueW(hKey, lpszName);
140 if (ret) goto cleanup;
141 }
142
143 cleanup:
144 if (lpszName != szNameBuf)
145 HeapFree(GetProcessHeap(), 0, lpszName);
146 if(lpszSubKey)
147 RegCloseKey(hSubKey);
148 return ret;
149 }
150
151 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
152 {
153 DWORD i,n=1;
154 GUID guid;
155
156 if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
157 return FALSE;
158
159 for(i=0; i<8; i++)
160 out[7-i] = in[n++];
161 n++;
162 for(i=0; i<4; i++)
163 out[11-i] = in[n++];
164 n++;
165 for(i=0; i<4; i++)
166 out[15-i] = in[n++];
167 n++;
168 for(i=0; i<2; i++)
169 {
170 out[17+i*2] = in[n++];
171 out[16+i*2] = in[n++];
172 }
173 n++;
174 for( ; i<8; i++)
175 {
176 out[17+i*2] = in[n++];
177 out[16+i*2] = in[n++];
178 }
179 out[32]=0;
180 return TRUE;
181 }
182
183 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
184 {
185 WCHAR guidW[MAX_PATH];
186 WCHAR squashedW[MAX_PATH];
187 GUID guid;
188 HRESULT hr;
189 int size;
190
191 hr = CoCreateGuid(&guid);
192 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
193
194 size = StringFromGUID2(&guid, guidW, MAX_PATH);
195 ok(size == 39, "Expected 39, got %d\n", hr);
196
197 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
198 squash_guid(guidW, squashedW);
199 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
200 }
201
202 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
203 LPCSTR guid, LPSTR usersid, BOOL dir)
204 {
205 WCHAR guidW[MAX_PATH];
206 WCHAR squashedW[MAX_PATH];
207 CHAR squashed[MAX_PATH];
208 CHAR comppath[MAX_PATH];
209 CHAR prodpath[MAX_PATH];
210 CHAR path[MAX_PATH];
211 LPCSTR prod = NULL;
212 HKEY hkey;
213
214 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
215 squash_guid(guidW, squashedW);
216 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
217
218 if (context == MSIINSTALLCONTEXT_MACHINE)
219 {
220 prod = "3D0DAE300FACA1300AD792060BCDAA92";
221 sprintf(comppath,
222 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
223 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
224 lstrcpyA(prodpath,
225 "SOFTWARE\\Classes\\Installer\\"
226 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
227 }
228 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
229 {
230 prod = "7D2F387510109040002000060BECB6AB";
231 sprintf(comppath,
232 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
233 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
234 sprintf(prodpath,
235 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
236 "Installer\\%s\\Installer\\Products\\"
237 "7D2F387510109040002000060BECB6AB", usersid);
238 }
239 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
240 {
241 prod = "7D2F387510109040002000060BECB6AB";
242 sprintf(comppath,
243 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
244 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
245 sprintf(prodpath,
246 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
247 "Installer\\Managed\\%s\\Installer\\Products\\"
248 "7D2F387510109040002000060BECB6AB", usersid);
249 }
250
251 RegCreateKeyA(HKEY_LOCAL_MACHINE, comppath, &hkey);
252
253 lstrcpyA(path, CURR_DIR);
254 lstrcatA(path, "\\");
255 if (!dir) lstrcatA(path, filename);
256
257 RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
258 RegCloseKey(hkey);
259
260 RegCreateKeyA(HKEY_LOCAL_MACHINE, prodpath, &hkey);
261 RegCloseKey(hkey);
262 }
263
264 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
265 {
266 WCHAR guidW[MAX_PATH];
267 WCHAR squashedW[MAX_PATH];
268 WCHAR substrW[MAX_PATH];
269 CHAR squashed[MAX_PATH];
270 CHAR comppath[MAX_PATH];
271 CHAR prodpath[MAX_PATH];
272
273 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
274 squash_guid(guidW, squashedW);
275 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
276
277 if (context == MSIINSTALLCONTEXT_MACHINE)
278 {
279 sprintf(comppath,
280 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
281 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
282 lstrcpyA(prodpath,
283 "SOFTWARE\\Classes\\Installer\\"
284 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
285 }
286 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
287 {
288 sprintf(comppath,
289 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
290 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
291 sprintf(prodpath,
292 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
293 "Installer\\%s\\Installer\\Products\\"
294 "7D2F387510109040002000060BECB6AB", usersid);
295 }
296 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
297 {
298 sprintf(comppath,
299 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
300 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
301 sprintf(prodpath,
302 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
303 "Installer\\Managed\\%s\\Installer\\Products\\"
304 "7D2F387510109040002000060BECB6AB", usersid);
305 }
306
307 MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
308 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
309
310 MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
311 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
312 }
313
314 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
315 {
316 MSIHANDLE hview = 0;
317 UINT r, ret;
318
319 /* open a select query */
320 r = MsiDatabaseOpenView(hdb, query, &hview);
321 if (r != ERROR_SUCCESS)
322 return r;
323 r = MsiViewExecute(hview, 0);
324 if (r != ERROR_SUCCESS)
325 return r;
326 ret = MsiViewFetch(hview, phrec);
327 r = MsiViewClose(hview);
328 if (r != ERROR_SUCCESS)
329 return r;
330 r = MsiCloseHandle(hview);
331 if (r != ERROR_SUCCESS)
332 return r;
333 return ret;
334 }
335
336 static UINT run_query( MSIHANDLE hdb, const char *query )
337 {
338 MSIHANDLE hview = 0;
339 UINT r;
340
341 r = MsiDatabaseOpenView(hdb, query, &hview);
342 if( r != ERROR_SUCCESS )
343 return r;
344
345 r = MsiViewExecute(hview, 0);
346 if( r == ERROR_SUCCESS )
347 r = MsiViewClose(hview);
348 MsiCloseHandle(hview);
349 return r;
350 }
351
352 static UINT create_component_table( MSIHANDLE hdb )
353 {
354 return run_query( hdb,
355 "CREATE TABLE `Component` ( "
356 "`Component` CHAR(72) NOT NULL, "
357 "`ComponentId` CHAR(38), "
358 "`Directory_` CHAR(72) NOT NULL, "
359 "`Attributes` SHORT NOT NULL, "
360 "`Condition` CHAR(255), "
361 "`KeyPath` CHAR(72) "
362 "PRIMARY KEY `Component`)" );
363 }
364
365 static UINT create_feature_table( MSIHANDLE hdb )
366 {
367 return run_query( hdb,
368 "CREATE TABLE `Feature` ( "
369 "`Feature` CHAR(38) NOT NULL, "
370 "`Feature_Parent` CHAR(38), "
371 "`Title` CHAR(64), "
372 "`Description` CHAR(255), "
373 "`Display` SHORT NOT NULL, "
374 "`Level` SHORT NOT NULL, "
375 "`Directory_` CHAR(72), "
376 "`Attributes` SHORT NOT NULL "
377 "PRIMARY KEY `Feature`)" );
378 }
379
380 static UINT create_feature_components_table( MSIHANDLE hdb )
381 {
382 return run_query( hdb,
383 "CREATE TABLE `FeatureComponents` ( "
384 "`Feature_` CHAR(38) NOT NULL, "
385 "`Component_` CHAR(72) NOT NULL "
386 "PRIMARY KEY `Feature_`, `Component_` )" );
387 }
388
389 static UINT create_file_table( MSIHANDLE hdb )
390 {
391 return run_query( hdb,
392 "CREATE TABLE `File` ("
393 "`File` CHAR(72) NOT NULL, "
394 "`Component_` CHAR(72) NOT NULL, "
395 "`FileName` CHAR(255) NOT NULL, "
396 "`FileSize` LONG NOT NULL, "
397 "`Version` CHAR(72), "
398 "`Language` CHAR(20), "
399 "`Attributes` SHORT, "
400 "`Sequence` SHORT NOT NULL "
401 "PRIMARY KEY `File`)" );
402 }
403
404 static UINT create_remove_file_table( MSIHANDLE hdb )
405 {
406 return run_query( hdb,
407 "CREATE TABLE `RemoveFile` ("
408 "`FileKey` CHAR(72) NOT NULL, "
409 "`Component_` CHAR(72) NOT NULL, "
410 "`FileName` CHAR(255) LOCALIZABLE, "
411 "`DirProperty` CHAR(72) NOT NULL, "
412 "`InstallMode` SHORT NOT NULL "
413 "PRIMARY KEY `FileKey`)" );
414 }
415
416 static UINT create_appsearch_table( MSIHANDLE hdb )
417 {
418 return run_query( hdb,
419 "CREATE TABLE `AppSearch` ("
420 "`Property` CHAR(72) NOT NULL, "
421 "`Signature_` CHAR(72) NOT NULL "
422 "PRIMARY KEY `Property`, `Signature_`)" );
423 }
424
425 static UINT create_reglocator_table( MSIHANDLE hdb )
426 {
427 return run_query( hdb,
428 "CREATE TABLE `RegLocator` ("
429 "`Signature_` CHAR(72) NOT NULL, "
430 "`Root` SHORT NOT NULL, "
431 "`Key` CHAR(255) NOT NULL, "
432 "`Name` CHAR(255), "
433 "`Type` SHORT "
434 "PRIMARY KEY `Signature_`)" );
435 }
436
437 static UINT create_signature_table( MSIHANDLE hdb )
438 {
439 return run_query( hdb,
440 "CREATE TABLE `Signature` ("
441 "`Signature` CHAR(72) NOT NULL, "
442 "`FileName` CHAR(255) NOT NULL, "
443 "`MinVersion` CHAR(20), "
444 "`MaxVersion` CHAR(20), "
445 "`MinSize` LONG, "
446 "`MaxSize` LONG, "
447 "`MinDate` LONG, "
448 "`MaxDate` LONG, "
449 "`Languages` CHAR(255) "
450 "PRIMARY KEY `Signature`)" );
451 }
452
453 static UINT create_launchcondition_table( MSIHANDLE hdb )
454 {
455 return run_query( hdb,
456 "CREATE TABLE `LaunchCondition` ("
457 "`Condition` CHAR(255) NOT NULL, "
458 "`Description` CHAR(255) NOT NULL "
459 "PRIMARY KEY `Condition`)" );
460 }
461
462 static UINT create_property_table( MSIHANDLE hdb )
463 {
464 return run_query( hdb,
465 "CREATE TABLE `Property` ("
466 "`Property` CHAR(72) NOT NULL, "
467 "`Value` CHAR(0) "
468 "PRIMARY KEY `Property`)" );
469 }
470
471 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
472 {
473 return run_query( hdb,
474 "CREATE TABLE `InstallExecuteSequence` ("
475 "`Action` CHAR(72) NOT NULL, "
476 "`Condition` CHAR(255), "
477 "`Sequence` SHORT "
478 "PRIMARY KEY `Action`)" );
479 }
480
481 static UINT create_media_table( MSIHANDLE hdb )
482 {
483 return run_query( hdb,
484 "CREATE TABLE `Media` ("
485 "`DiskId` SHORT NOT NULL, "
486 "`LastSequence` SHORT NOT NULL, "
487 "`DiskPrompt` CHAR(64), "
488 "`Cabinet` CHAR(255), "
489 "`VolumeLabel` CHAR(32), "
490 "`Source` CHAR(72) "
491 "PRIMARY KEY `DiskId`)" );
492 }
493
494 static UINT create_ccpsearch_table( MSIHANDLE hdb )
495 {
496 return run_query( hdb,
497 "CREATE TABLE `CCPSearch` ("
498 "`Signature_` CHAR(72) NOT NULL "
499 "PRIMARY KEY `Signature_`)" );
500 }
501
502 static UINT create_drlocator_table( MSIHANDLE hdb )
503 {
504 return run_query( hdb,
505 "CREATE TABLE `DrLocator` ("
506 "`Signature_` CHAR(72) NOT NULL, "
507 "`Parent` CHAR(72), "
508 "`Path` CHAR(255), "
509 "`Depth` SHORT "
510 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
511 }
512
513 static UINT create_complocator_table( MSIHANDLE hdb )
514 {
515 return run_query( hdb,
516 "CREATE TABLE `CompLocator` ("
517 "`Signature_` CHAR(72) NOT NULL, "
518 "`ComponentId` CHAR(38) NOT NULL, "
519 "`Type` SHORT "
520 "PRIMARY KEY `Signature_`)" );
521 }
522
523 static UINT create_inilocator_table( MSIHANDLE hdb )
524 {
525 return run_query( hdb,
526 "CREATE TABLE `IniLocator` ("
527 "`Signature_` CHAR(72) NOT NULL, "
528 "`FileName` CHAR(255) NOT NULL, "
529 "`Section` CHAR(96)NOT NULL, "
530 "`Key` CHAR(128)NOT NULL, "
531 "`Field` SHORT, "
532 "`Type` SHORT "
533 "PRIMARY KEY `Signature_`)" );
534 }
535
536 #define make_add_entry(type, qtext) \
537 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
538 { \
539 char insert[] = qtext; \
540 char *query; \
541 UINT sz, r; \
542 sz = strlen(values) + sizeof insert; \
543 query = HeapAlloc(GetProcessHeap(),0,sz); \
544 sprintf(query,insert,values); \
545 r = run_query( hdb, query ); \
546 HeapFree(GetProcessHeap(), 0, query); \
547 return r; \
548 }
549
550 make_add_entry(component,
551 "INSERT INTO `Component` "
552 "(`Component`, `ComponentId`, `Directory_`, "
553 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
554
555 make_add_entry(directory,
556 "INSERT INTO `Directory` "
557 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
558
559 make_add_entry(feature,
560 "INSERT INTO `Feature` "
561 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
562 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
563
564 make_add_entry(feature_components,
565 "INSERT INTO `FeatureComponents` "
566 "(`Feature_`, `Component_`) VALUES( %s )")
567
568 make_add_entry(file,
569 "INSERT INTO `File` "
570 "(`File`, `Component_`, `FileName`, `FileSize`, "
571 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
572
573 make_add_entry(appsearch,
574 "INSERT INTO `AppSearch` "
575 "(`Property`, `Signature_`) VALUES( %s )")
576
577 make_add_entry(reglocator,
578 "INSERT INTO `RegLocator` "
579 "(`Signature_`, `Root`, `Key`, `Name`, `Type`) VALUES( %s )")
580
581 make_add_entry(signature,
582 "INSERT INTO `Signature` "
583 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
584 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
585 "VALUES( %s )")
586
587 make_add_entry(launchcondition,
588 "INSERT INTO `LaunchCondition` "
589 "(`Condition`, `Description`) VALUES( %s )")
590
591 make_add_entry(property,
592 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
593
594 make_add_entry(install_execute_sequence,
595 "INSERT INTO `InstallExecuteSequence` "
596 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
597
598 make_add_entry(media,
599 "INSERT INTO `Media` "
600 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
601 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
602
603 make_add_entry(ccpsearch,
604 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
605
606 make_add_entry(drlocator,
607 "INSERT INTO `DrLocator` "
608 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
609
610 make_add_entry(complocator,
611 "INSERT INTO `CompLocator` "
612 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
613
614 make_add_entry(inilocator,
615 "INSERT INTO `IniLocator` "
616 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
617 "VALUES( %s )")
618
619 static UINT set_summary_info(MSIHANDLE hdb)
620 {
621 UINT res;
622 MSIHANDLE suminfo;
623
624 /* build summary info */
625 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
626 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
627
628 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
629 "Installation Database");
630 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
631
632 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
633 "Installation Database");
634 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
635
636 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
637 "Wine Hackers");
638 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
639
640 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
641 ";1033");
642 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
643
644 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
645 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
646 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
647
648 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
649 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
650
651 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
652 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
653
654 res = MsiSummaryInfoPersist(suminfo);
655 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
656
657 res = MsiCloseHandle( suminfo);
658 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
659
660 return res;
661 }
662
663
664 static MSIHANDLE create_package_db(void)
665 {
666 MSIHANDLE hdb = 0;
667 UINT res;
668
669 DeleteFile(msifile);
670
671 /* create an empty database */
672 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
673 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
674 if( res != ERROR_SUCCESS )
675 return hdb;
676
677 res = MsiDatabaseCommit( hdb );
678 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
679
680 res = set_summary_info(hdb);
681
682 res = run_query( hdb,
683 "CREATE TABLE `Directory` ( "
684 "`Directory` CHAR(255) NOT NULL, "
685 "`Directory_Parent` CHAR(255), "
686 "`DefaultDir` CHAR(255) NOT NULL "
687 "PRIMARY KEY `Directory`)" );
688 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
689
690 return hdb;
691 }
692
693 static MSIHANDLE package_from_db(MSIHANDLE hdb)
694 {
695 UINT res;
696 CHAR szPackage[10];
697 MSIHANDLE hPackage;
698
699 sprintf(szPackage,"#%i",hdb);
700 res = MsiOpenPackage(szPackage,&hPackage);
701 if (res != ERROR_SUCCESS)
702 return 0;
703
704 res = MsiCloseHandle(hdb);
705 if (res != ERROR_SUCCESS)
706 return 0;
707
708 return hPackage;
709 }
710
711 static void create_test_file(const CHAR *name)
712 {
713 HANDLE file;
714 DWORD written;
715
716 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
717 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
718 WriteFile(file, name, strlen(name), &written, NULL);
719 WriteFile(file, "\n", strlen("\n"), &written, NULL);
720 CloseHandle(file);
721 }
722
723 typedef struct _tagVS_VERSIONINFO
724 {
725 WORD wLength;
726 WORD wValueLength;
727 WORD wType;
728 WCHAR szKey[1];
729 WORD wPadding1[1];
730 VS_FIXEDFILEINFO Value;
731 WORD wPadding2[1];
732 WORD wChildren[1];
733 } VS_VERSIONINFO;
734
735 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
736 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
737
738 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
739 {
740 VS_VERSIONINFO *pVerInfo;
741 VS_FIXEDFILEINFO *pFixedInfo;
742 LPBYTE buffer, ofs;
743 CHAR path[MAX_PATH];
744 DWORD handle, size;
745 HANDLE resource;
746 BOOL ret = FALSE;
747
748 GetSystemDirectory(path, MAX_PATH);
749 /* Some dlls can't be updated on Vista/W2K8 */
750 lstrcatA(path, "\\version.dll");
751
752 CopyFileA(path, name, FALSE);
753
754 size = GetFileVersionInfoSize(path, &handle);
755 buffer = HeapAlloc(GetProcessHeap(), 0, size);
756
757 GetFileVersionInfoA(path, 0, size, buffer);
758
759 pVerInfo = (VS_VERSIONINFO *)buffer;
760 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
761 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
762
763 pFixedInfo->dwFileVersionMS = ms;
764 pFixedInfo->dwFileVersionLS = ls;
765 pFixedInfo->dwProductVersionMS = ms;
766 pFixedInfo->dwProductVersionLS = ls;
767
768 resource = BeginUpdateResource(name, FALSE);
769 if (!resource)
770 goto done;
771
772 if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
773 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
774 goto done;
775
776 if (!EndUpdateResource(resource, FALSE))
777 goto done;
778
779 ret = TRUE;
780
781 done:
782 HeapFree(GetProcessHeap(), 0, buffer);
783 return ret;
784 }
785
786 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
787 {
788 RESTOREPOINTINFOA spec;
789
790 spec.dwEventType = event_type;
791 spec.dwRestorePtType = APPLICATION_INSTALL;
792 spec.llSequenceNumber = status->llSequenceNumber;
793 lstrcpyA(spec.szDescription, "msitest restore point");
794
795 return pSRSetRestorePointA(&spec, status);
796 }
797
798 static void remove_restore_point(DWORD seq_number)
799 {
800 DWORD res;
801
802 res = pSRRemoveRestorePoint(seq_number);
803 if (res != ERROR_SUCCESS)
804 trace("Failed to remove the restore point : %08x\n", res);
805 }
806
807 static void test_createpackage(void)
808 {
809 MSIHANDLE hPackage = 0;
810 UINT res;
811
812 hPackage = package_from_db(create_package_db());
813 ok( hPackage != 0, " Failed to create package\n");
814
815 res = MsiCloseHandle( hPackage);
816 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
817 DeleteFile(msifile);
818 }
819
820 static void test_doaction( void )
821 {
822 MSIHANDLE hpkg;
823 UINT r;
824
825 r = MsiDoAction( -1, NULL );
826 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
827
828 hpkg = package_from_db(create_package_db());
829 ok( hpkg, "failed to create package\n");
830
831 r = MsiDoAction(hpkg, NULL);
832 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
833
834 r = MsiDoAction(0, "boo");
835 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
836
837 r = MsiDoAction(hpkg, "boo");
838 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
839
840 MsiCloseHandle( hpkg );
841 DeleteFile(msifile);
842 }
843
844 static void test_gettargetpath_bad(void)
845 {
846 char buffer[0x80];
847 MSIHANDLE hpkg;
848 DWORD sz;
849 UINT r;
850
851 hpkg = package_from_db(create_package_db());
852 ok( hpkg, "failed to create package\n");
853
854 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
855 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
856
857 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
858 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
859
860 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
861 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
862
863 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
864 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
865
866 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
867 ok( r == ERROR_DIRECTORY, "wrong return val\n");
868
869 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
870 ok( r == ERROR_DIRECTORY, "wrong return val\n");
871
872 MsiCloseHandle( hpkg );
873 DeleteFile(msifile);
874 }
875
876 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
877 {
878 UINT r;
879 DWORD size;
880 MSIHANDLE rec;
881
882 rec = MsiCreateRecord( 1 );
883 ok(rec, "MsiCreate record failed\n");
884
885 r = MsiRecordSetString( rec, 0, file );
886 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
887
888 size = MAX_PATH;
889 r = MsiFormatRecord( hpkg, rec, buff, &size );
890 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
891
892 MsiCloseHandle( rec );
893 }
894
895 static void test_settargetpath(void)
896 {
897 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
898 DWORD sz;
899 MSIHANDLE hpkg;
900 UINT r;
901 MSIHANDLE hdb;
902
903 hdb = create_package_db();
904 ok ( hdb, "failed to create package database\n" );
905
906 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
907 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
908
909 r = create_component_table( hdb );
910 ok( r == S_OK, "cannot create Component table: %d\n", r );
911
912 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
913 ok( r == S_OK, "cannot add dummy component: %d\n", r );
914
915 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
916 ok( r == S_OK, "cannot add test component: %d\n", r );
917
918 r = create_feature_table( hdb );
919 ok( r == S_OK, "cannot create Feature table: %d\n", r );
920
921 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
922 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
923
924 r = create_feature_components_table( hdb );
925 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
926
927 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
928 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
929
930 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
931 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
932
933 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
934 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
935
936 r = create_file_table( hdb );
937 ok( r == S_OK, "cannot create File table: %d\n", r );
938
939 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
940 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
941
942 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
943 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
944
945 hpkg = package_from_db( hdb );
946 ok( hpkg, "failed to create package\n");
947
948 r = MsiDoAction( hpkg, "CostInitialize");
949 ok( r == ERROR_SUCCESS, "cost init failed\n");
950
951 r = MsiDoAction( hpkg, "FileCost");
952 ok( r == ERROR_SUCCESS, "file cost failed\n");
953
954 r = MsiDoAction( hpkg, "CostFinalize");
955 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
956
957 r = MsiSetTargetPath( 0, NULL, NULL );
958 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
959
960 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
961 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
962
963 r = MsiSetTargetPath( hpkg, "boo", NULL );
964 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
965
966 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
967 ok( r == ERROR_DIRECTORY, "wrong return val\n");
968
969 sz = sizeof tempdir - 1;
970 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
971 sprintf( file, "%srootfile.txt", tempdir );
972 buffer[0] = 0;
973 query_file_path( hpkg, "[#RootFile]", buffer );
974 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
975 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
976
977 GetTempFileName( tempdir, "_wt", 0, buffer );
978 sprintf( tempdir, "%s\\subdir", buffer );
979
980 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
981 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
982 "MsiSetTargetPath on file returned %d\n", r );
983
984 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
985 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
986 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
987
988 DeleteFile( buffer );
989
990 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
991 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
992
993 r = GetFileAttributes( buffer );
994 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
995
996 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
997 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
998
999 sz = sizeof buffer - 1;
1000 lstrcat( tempdir, "\\" );
1001 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1002 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1003 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1004
1005 sprintf( file, "%srootfile.txt", tempdir );
1006 query_file_path( hpkg, "[#RootFile]", buffer );
1007 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1008
1009 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1010 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1011
1012 query_file_path( hpkg, "[#TestFile]", buffer );
1013 ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1014 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1015
1016 sz = sizeof buffer - 1;
1017 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1018 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1019 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1020
1021 MsiCloseHandle( hpkg );
1022 }
1023
1024 static void test_condition(void)
1025 {
1026 MSICONDITION r;
1027 MSIHANDLE hpkg;
1028
1029 hpkg = package_from_db(create_package_db());
1030 ok( hpkg, "failed to create package\n");
1031
1032 r = MsiEvaluateCondition(0, NULL);
1033 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1034
1035 r = MsiEvaluateCondition(hpkg, NULL);
1036 ok( r == MSICONDITION_NONE, "wrong return val\n");
1037
1038 r = MsiEvaluateCondition(hpkg, "");
1039 ok( r == MSICONDITION_NONE, "wrong return val\n");
1040
1041 r = MsiEvaluateCondition(hpkg, "1");
1042 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1043
1044 r = MsiEvaluateCondition(hpkg, "0");
1045 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1046
1047 r = MsiEvaluateCondition(hpkg, "-1");
1048 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1049
1050 r = MsiEvaluateCondition(hpkg, "0 = 0");
1051 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1052
1053 r = MsiEvaluateCondition(hpkg, "0 <> 0");
1054 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1055
1056 r = MsiEvaluateCondition(hpkg, "0 = 1");
1057 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1058
1059 r = MsiEvaluateCondition(hpkg, "0 > 1");
1060 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1061
1062 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1063 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1064
1065 r = MsiEvaluateCondition(hpkg, "1 > 1");
1066 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1067
1068 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1069 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1070
1071 r = MsiEvaluateCondition(hpkg, "0 >= 1");
1072 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1073
1074 r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1075 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1076
1077 r = MsiEvaluateCondition(hpkg, "1 >= 1");
1078 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1079
1080 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1081 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1082
1083 r = MsiEvaluateCondition(hpkg, "0 < 1");
1084 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1085
1086 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1087 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1088
1089 r = MsiEvaluateCondition(hpkg, "1 < 1");
1090 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1091
1092 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1093 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1094
1095 r = MsiEvaluateCondition(hpkg, "0 <= 1");
1096 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1097
1098 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1099 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1100
1101 r = MsiEvaluateCondition(hpkg, "1 <= 1");
1102 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1103
1104 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1105 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1106
1107 r = MsiEvaluateCondition(hpkg, "0 >=");
1108 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1109
1110 r = MsiEvaluateCondition(hpkg, " ");
1111 ok( r == MSICONDITION_NONE, "wrong return val\n");
1112
1113 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1114 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1115
1116 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1117 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1118
1119 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1120 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1121
1122 r = MsiEvaluateCondition(hpkg, "not 0");
1123 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1124
1125 r = MsiEvaluateCondition(hpkg, "not LicView");
1126 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1127
1128 r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1129 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1130
1131 r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1132 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1133
1134 r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1135 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1136
1137 r = MsiEvaluateCondition(hpkg, "not \"A\"");
1138 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1139
1140 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1141 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1142
1143 r = MsiEvaluateCondition(hpkg, "\"0\"");
1144 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1145
1146 r = MsiEvaluateCondition(hpkg, "1 and 2");
1147 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1148
1149 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1150 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1151
1152 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1153 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1154
1155 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1156 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1157
1158 r = MsiEvaluateCondition(hpkg, "(0)");
1159 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1160
1161 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1162 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1163
1164 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1165 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1166
1167 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1168 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1169
1170 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1171 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1172
1173 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1174 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1175
1176 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1177 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1178
1179 r = MsiEvaluateCondition(hpkg, "0 < > 0");
1180 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1181
1182 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1183 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1184
1185 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1186 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1187
1188 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1189 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1190
1191 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1192 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1193
1194 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1195 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1196
1197 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1198 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1199
1200 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1201 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1202
1203 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1204 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1205
1206 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1207 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1208
1209 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1210 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1211
1212 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1213 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1214
1215 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1216 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1217
1218 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1219 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1220
1221 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1222 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1223
1224 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1225 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1226
1227 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1228 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1229
1230 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1231 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1232
1233 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1234 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1235
1236 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1237 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1238
1239 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1240 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1241
1242 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1243 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1244
1245 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1246 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1247
1248 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1249 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1250
1251 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1252 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1253
1254 MsiSetProperty(hpkg, "mm", "5" );
1255
1256 r = MsiEvaluateCondition(hpkg, "mm = 5");
1257 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258
1259 r = MsiEvaluateCondition(hpkg, "mm < 6");
1260 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1261
1262 r = MsiEvaluateCondition(hpkg, "mm <= 5");
1263 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1264
1265 r = MsiEvaluateCondition(hpkg, "mm > 4");
1266 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1267
1268 r = MsiEvaluateCondition(hpkg, "mm < 12");
1269 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1270
1271 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1272 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273
1274 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1275 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1276
1277 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1278 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1279
1280 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1281 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1282
1283 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1284 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1285
1286 r = MsiEvaluateCondition(hpkg, "3 >< 1");
1287 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1288
1289 r = MsiEvaluateCondition(hpkg, "3 >< 4");
1290 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1291
1292 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1293 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1296 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1297
1298 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1299 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300
1301 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1302 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303
1304 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1305 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306
1307 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1308 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1309
1310 r = MsiEvaluateCondition(hpkg, "_1 = _1");
1311 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1312
1313 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1314 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1315
1316 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1317 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1318
1319 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1320 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1321
1322 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1323 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1324
1325 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1326 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1327
1328 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1329 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330
1331 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1332 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333
1334 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1335 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1336
1337 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1338 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1339
1340 r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1341 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1342
1343 r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1344 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345
1346 r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1347 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1348
1349 MsiSetProperty(hpkg, "bandalmael", "0" );
1350 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1351 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1352
1353 MsiSetProperty(hpkg, "bandalmael", "" );
1354 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1355 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1356
1357 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1358 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1359 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1360
1361 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1362 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1363 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1364
1365 MsiSetProperty(hpkg, "bandalmael", "0 " );
1366 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1367 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1368
1369 MsiSetProperty(hpkg, "bandalmael", "-0" );
1370 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1371 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1372
1373 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1374 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1375 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1376
1377 MsiSetProperty(hpkg, "bandalmael", "--0" );
1378 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1379 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1380
1381 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1382 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1383 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1384
1385 MsiSetProperty(hpkg, "bandalmael", "-" );
1386 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1387 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1388
1389 MsiSetProperty(hpkg, "bandalmael", "+0" );
1390 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1391 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1392
1393 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1394 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1395 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1396 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1397 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1398
1399 MsiSetProperty(hpkg, "one", "hi");
1400 MsiSetProperty(hpkg, "two", "hithere");
1401 r = MsiEvaluateCondition(hpkg, "one >< two");
1402 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1403
1404 MsiSetProperty(hpkg, "one", "hithere");
1405 MsiSetProperty(hpkg, "two", "hi");
1406 r = MsiEvaluateCondition(hpkg, "one >< two");
1407 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1408
1409 MsiSetProperty(hpkg, "one", "hello");
1410 MsiSetProperty(hpkg, "two", "hi");
1411 r = MsiEvaluateCondition(hpkg, "one >< two");
1412 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1413
1414 MsiSetProperty(hpkg, "one", "hellohithere");
1415 MsiSetProperty(hpkg, "two", "hi");
1416 r = MsiEvaluateCondition(hpkg, "one >< two");
1417 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1418
1419 MsiSetProperty(hpkg, "one", "");
1420 MsiSetProperty(hpkg, "two", "hi");
1421 r = MsiEvaluateCondition(hpkg, "one >< two");
1422 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1423
1424 MsiSetProperty(hpkg, "one", "hi");
1425 MsiSetProperty(hpkg, "two", "");
1426 r = MsiEvaluateCondition(hpkg, "one >< two");
1427 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1428
1429 MsiSetProperty(hpkg, "one", "");
1430 MsiSetProperty(hpkg, "two", "");
1431 r = MsiEvaluateCondition(hpkg, "one >< two");
1432 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1433
1434 MsiSetProperty(hpkg, "one", "1234");
1435 MsiSetProperty(hpkg, "two", "1");
1436 r = MsiEvaluateCondition(hpkg, "one >< two");
1437 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1438
1439 MsiSetProperty(hpkg, "one", "one 1234");
1440 MsiSetProperty(hpkg, "two", "1");
1441 r = MsiEvaluateCondition(hpkg, "one >< two");
1442 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443
1444 MsiSetProperty(hpkg, "one", "hithere");
1445 MsiSetProperty(hpkg, "two", "hi");
1446 r = MsiEvaluateCondition(hpkg, "one << two");
1447 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1448
1449 MsiSetProperty(hpkg, "one", "hi");
1450 MsiSetProperty(hpkg, "two", "hithere");
1451 r = MsiEvaluateCondition(hpkg, "one << two");
1452 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1453
1454 MsiSetProperty(hpkg, "one", "hi");
1455 MsiSetProperty(hpkg, "two", "hi");
1456 r = MsiEvaluateCondition(hpkg, "one << two");
1457 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1458
1459 MsiSetProperty(hpkg, "one", "abcdhithere");
1460 MsiSetProperty(hpkg, "two", "hi");
1461 r = MsiEvaluateCondition(hpkg, "one << two");
1462 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1463
1464 MsiSetProperty(hpkg, "one", "");
1465 MsiSetProperty(hpkg, "two", "hi");
1466 r = MsiEvaluateCondition(hpkg, "one << two");
1467 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1468
1469 MsiSetProperty(hpkg, "one", "hithere");
1470 MsiSetProperty(hpkg, "two", "");
1471 r = MsiEvaluateCondition(hpkg, "one << two");
1472 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1473
1474 MsiSetProperty(hpkg, "one", "");
1475 MsiSetProperty(hpkg, "two", "");
1476 r = MsiEvaluateCondition(hpkg, "one << two");
1477 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1478
1479 MsiSetProperty(hpkg, "one", "1234");
1480 MsiSetProperty(hpkg, "two", "1");
1481 r = MsiEvaluateCondition(hpkg, "one << two");
1482 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1483
1484 MsiSetProperty(hpkg, "one", "1234 one");
1485 MsiSetProperty(hpkg, "two", "1");
1486 r = MsiEvaluateCondition(hpkg, "one << two");
1487 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488
1489 MsiSetProperty(hpkg, "one", "hithere");
1490 MsiSetProperty(hpkg, "two", "there");
1491 r = MsiEvaluateCondition(hpkg, "one >> two");
1492 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1493
1494 MsiSetProperty(hpkg, "one", "hithere");
1495 MsiSetProperty(hpkg, "two", "hi");
1496 r = MsiEvaluateCondition(hpkg, "one >> two");
1497 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1498
1499 MsiSetProperty(hpkg, "one", "there");
1500 MsiSetProperty(hpkg, "two", "hithere");
1501 r = MsiEvaluateCondition(hpkg, "one >> two");
1502 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1503
1504 MsiSetProperty(hpkg, "one", "there");
1505 MsiSetProperty(hpkg, "two", "there");
1506 r = MsiEvaluateCondition(hpkg, "one >> two");
1507 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1508
1509 MsiSetProperty(hpkg, "one", "abcdhithere");
1510 MsiSetProperty(hpkg, "two", "hi");
1511 r = MsiEvaluateCondition(hpkg, "one >> two");
1512 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1513
1514 MsiSetProperty(hpkg, "one", "");
1515 MsiSetProperty(hpkg, "two", "there");
1516 r = MsiEvaluateCondition(hpkg, "one >> two");
1517 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1518
1519 MsiSetProperty(hpkg, "one", "there");
1520 MsiSetProperty(hpkg, "two", "");
1521 r = MsiEvaluateCondition(hpkg, "one >> two");
1522 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1523
1524 MsiSetProperty(hpkg, "one", "");
1525 MsiSetProperty(hpkg, "two", "");
1526 r = MsiEvaluateCondition(hpkg, "one >> two");
1527 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1528
1529 MsiSetProperty(hpkg, "one", "1234");
1530 MsiSetProperty(hpkg, "two", "4");
1531 r = MsiEvaluateCondition(hpkg, "one >> two");
1532 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1533
1534 MsiSetProperty(hpkg, "one", "one 1234");
1535 MsiSetProperty(hpkg, "two", "4");
1536 r = MsiEvaluateCondition(hpkg, "one >> two");
1537 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1538
1539 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1540
1541 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1542 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1543
1544 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1545 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1546
1547 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1548 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1549
1550 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1551 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1552
1553 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1554 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1555
1556 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1557 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1558
1559 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1560 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1561
1562 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1563 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1564
1565 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1566 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1567
1568 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1569 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1570
1571 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1572 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1573
1574 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1575 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1576
1577 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1578 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1579
1580 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1581 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1582
1583 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1584 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1585
1586 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1587 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1588
1589 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1590 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1591
1592 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1593 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1594
1595 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1596 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1597
1598 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1599 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1600
1601 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1602 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1603
1604 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1605 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1606
1607 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1608 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1609
1610 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1611 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1612
1613 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1614 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1615
1616 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1617 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1618
1619 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1620 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1621
1622 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1623 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1624
1625 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1626 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1627
1628 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1629 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1630
1631 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1632 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1633
1634 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1635 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1636
1637 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1638 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1639
1640 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1641 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1642
1643 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1644 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1645
1646 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1647 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1648
1649 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1650 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1651
1652 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1653 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1654 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1655
1656 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1657 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1658
1659 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1660 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1661
1662 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1663 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1664
1665 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1666 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1667
1668 MsiSetProperty(hpkg, "one", "1");
1669 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1670 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1671
1672 MsiSetProperty(hpkg, "X", "5.0");
1673
1674 r = MsiEvaluateCondition(hpkg, "X != \"\"");
1675 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1676
1677 r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1678 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1679
1680 r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1681 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1682
1683 r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1684 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1685
1686 r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1687 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1688
1689 r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1690 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1691
1692 r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1693 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1694
1695 /* feature doesn't exist */
1696 r = MsiEvaluateCondition(hpkg, "&nofeature");
1697 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1698
1699 MsiSetProperty(hpkg, "A", "2");
1700 MsiSetProperty(hpkg, "X", "50");
1701
1702 r = MsiEvaluateCondition(hpkg, "2 <= X");
1703 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1704
1705 r = MsiEvaluateCondition(hpkg, "A <= X");
1706 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1707
1708 r = MsiEvaluateCondition(hpkg, "A <= 50");
1709 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1710
1711 MsiSetProperty(hpkg, "X", "50val");
1712
1713 r = MsiEvaluateCondition(hpkg, "2 <= X");
1714 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1715
1716 r = MsiEvaluateCondition(hpkg, "A <= X");
1717 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1718
1719 MsiSetProperty(hpkg, "A", "7");
1720 MsiSetProperty(hpkg, "X", "50");
1721
1722 r = MsiEvaluateCondition(hpkg, "7 <= X");
1723 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1724
1725 r = MsiEvaluateCondition(hpkg, "A <= X");
1726 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1727
1728 r = MsiEvaluateCondition(hpkg, "A <= 50");
1729 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1730
1731 MsiSetProperty(hpkg, "X", "50val");
1732
1733 r = MsiEvaluateCondition(hpkg, "2 <= X");
1734 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1735
1736 r = MsiEvaluateCondition(hpkg, "A <= X");
1737 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1738
1739 MsiCloseHandle( hpkg );
1740 DeleteFile(msifile);
1741 }
1742
1743 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1744 {
1745 UINT r;
1746 DWORD sz;
1747 char buffer[2];
1748
1749 sz = sizeof buffer;
1750 strcpy(buffer,"x");
1751 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1752 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1753 }
1754
1755 static void test_props(void)
1756 {
1757 MSIHANDLE hpkg, hdb;
1758 UINT r;
1759 DWORD sz;
1760 char buffer[0x100];
1761
1762 hdb = create_package_db();
1763 r = run_query( hdb,
1764 "CREATE TABLE `Property` ( "
1765 "`Property` CHAR(255) NOT NULL, "
1766 "`Value` CHAR(255) "
1767 "PRIMARY KEY `Property`)" );
1768 ok( r == ERROR_SUCCESS , "Failed\n" );
1769
1770 r = run_query(hdb,
1771 "INSERT INTO `Property` "
1772 "(`Property`, `Value`) "
1773 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1774 ok( r == ERROR_SUCCESS , "Failed\n" );
1775
1776 hpkg = package_from_db( hdb );
1777 ok( hpkg, "failed to create package\n");
1778
1779 /* test invalid values */
1780 r = MsiGetProperty( 0, NULL, NULL, NULL );
1781 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1782
1783 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1784 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1785
1786 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1787 ok( r == ERROR_SUCCESS, "wrong return val\n");
1788
1789 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1790 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1791
1792 /* test retrieving an empty/nonexistent property */
1793 sz = sizeof buffer;
1794 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1795 ok( r == ERROR_SUCCESS, "wrong return val\n");
1796 ok( sz == 0, "wrong size returned\n");
1797
1798 check_prop_empty( hpkg, "boo");
1799 sz = 0;
1800 strcpy(buffer,"x");
1801 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1802 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1803 ok( !strcmp(buffer,"x"), "buffer was changed\n");
1804 ok( sz == 0, "wrong size returned\n");
1805
1806 sz = 1;
1807 strcpy(buffer,"x");
1808 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1809 ok( r == ERROR_SUCCESS, "wrong return val\n");
1810 ok( buffer[0] == 0, "buffer was not changed\n");
1811 ok( sz == 0, "wrong size returned\n");
1812
1813 /* set the property to something */
1814 r = MsiSetProperty( 0, NULL, NULL );
1815 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1816
1817 r = MsiSetProperty( hpkg, NULL, NULL );
1818 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1819
1820 r = MsiSetProperty( hpkg, "", NULL );
1821 ok( r == ERROR_SUCCESS, "wrong return val\n");
1822
1823 /* try set and get some illegal property identifiers */
1824 r = MsiSetProperty( hpkg, "", "asdf" );
1825 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1826
1827 r = MsiSetProperty( hpkg, "=", "asdf" );
1828 ok( r == ERROR_SUCCESS, "wrong return val\n");
1829
1830 r = MsiSetProperty( hpkg, " ", "asdf" );
1831 ok( r == ERROR_SUCCESS, "wrong return val\n");
1832
1833 r = MsiSetProperty( hpkg, "'", "asdf" );
1834 ok( r == ERROR_SUCCESS, "wrong return val\n");
1835
1836 sz = sizeof buffer;
1837 buffer[0]=0;
1838 r = MsiGetProperty( hpkg, "'", buffer, &sz );
1839 ok( r == ERROR_SUCCESS, "wrong return val\n");
1840 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1841
1842 /* set empty values */
1843 r = MsiSetProperty( hpkg, "boo", NULL );
1844 ok( r == ERROR_SUCCESS, "wrong return val\n");
1845 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1846
1847 r = MsiSetProperty( hpkg, "boo", "" );
1848 ok( r == ERROR_SUCCESS, "wrong return val\n");
1849 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1850
1851 /* set a non-empty value */
1852 r = MsiSetProperty( hpkg, "boo", "xyz" );
1853 ok( r == ERROR_SUCCESS, "wrong return val\n");
1854
1855 sz = 1;
1856 strcpy(buffer,"x");
1857 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1858 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1859 ok( buffer[0] == 0, "buffer was not changed\n");
1860 ok( sz == 3, "wrong size returned\n");
1861
1862 sz = 4;
1863 strcpy(buffer,"x");
1864 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1865 ok( r == ERROR_SUCCESS, "wrong return val\n");
1866 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1867 ok( sz == 3, "wrong size returned\n");
1868
1869 sz = 3;
1870 strcpy(buffer,"x");
1871 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1872 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1873 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1874 ok( sz == 3, "wrong size returned\n");
1875
1876 r = MsiSetProperty(hpkg, "SourceDir", "foo");
1877 ok( r == ERROR_SUCCESS, "wrong return val\n");
1878
1879 sz = 4;
1880 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1881 ok( r == ERROR_SUCCESS, "wrong return val\n");
1882 ok( !strcmp(buffer,""), "buffer wrong\n");
1883 ok( sz == 0, "wrong size returned\n");
1884
1885 sz = 4;
1886 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1887 ok( r == ERROR_SUCCESS, "wrong return val\n");
1888 ok( !strcmp(buffer,""), "buffer wrong\n");
1889 ok( sz == 0, "wrong size returned\n");
1890
1891 sz = 4;
1892 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1893 ok( r == ERROR_SUCCESS, "wrong return val\n");
1894 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1895 ok( sz == 3, "wrong size returned\n");
1896
1897 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1898 ok( r == ERROR_SUCCESS, "wrong return val\n");
1899
1900 sz = 0;
1901 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1902 ok( r == ERROR_SUCCESS, "return wrong\n");
1903 ok( sz == 13, "size wrong (%d)\n", sz);
1904
1905 sz = 13;
1906 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1907 ok( r == ERROR_MORE_DATA, "return wrong\n");
1908 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1909
1910 r = MsiSetProperty(hpkg, "property", "value");
1911 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1912
1913 sz = 6;
1914 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1915 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1916 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1917
1918 r = MsiSetProperty(hpkg, "property", NULL);
1919 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1920
1921 sz = 6;
1922 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1923 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1924 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1925
1926 MsiCloseHandle( hpkg );
1927 DeleteFile(msifile);
1928 }
1929
1930 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
1931 {
1932 MSIHANDLE hview, hrec;
1933 BOOL found;
1934 CHAR buffer[MAX_PATH];
1935 DWORD sz;
1936 UINT r;
1937
1938 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
1939 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1940 r = MsiViewExecute(hview, 0);
1941 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
1942
1943 found = FALSE;
1944 while (r == ERROR_SUCCESS && !found)
1945 {
1946 r = MsiViewFetch(hview, &hrec);
1947 if (r != ERROR_SUCCESS) break;
1948
1949 sz = MAX_PATH;
1950 r = MsiRecordGetString(hrec, 1, buffer, &sz);
1951 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
1952 {
1953 sz = MAX_PATH;
1954 r = MsiRecordGetString(hrec, 2, buffer, &sz);
1955 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
1956 found = TRUE;
1957 }
1958
1959 MsiCloseHandle(hrec);
1960 }
1961
1962 MsiViewClose(hview);
1963 MsiCloseHandle(hview);
1964
1965 return found;
1966 }
1967
1968 static void test_property_table(void)
1969 {
1970 const char *query;
1971 UINT r;
1972 MSIHANDLE hpkg, hdb, hrec;
1973 char buffer[MAX_PATH];
1974 DWORD sz;
1975 BOOL found;
1976
1977 hdb = create_package_db();
1978 ok( hdb, "failed to create package\n");
1979
1980 hpkg = package_from_db(hdb);
1981 ok( hpkg, "failed to create package\n");
1982
1983 MsiCloseHandle(hdb);
1984
1985 hdb = MsiGetActiveDatabase(hpkg);
1986
1987 query = "CREATE TABLE `_Property` ( "
1988 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1989 r = run_query(hdb, query);
1990 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1991
1992 MsiCloseHandle(hdb);
1993 MsiCloseHandle(hpkg);
1994 DeleteFile(msifile);
1995
1996 hdb = create_package_db();
1997 ok( hdb, "failed to create package\n");
1998
1999 query = "CREATE TABLE `_Property` ( "
2000 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2001 r = run_query(hdb, query);
2002 ok(r == ERROR_SUCCESS, "failed to create table\n");
2003
2004 query = "ALTER `_Property` ADD `foo` INTEGER";
2005 r = run_query(hdb, query);
2006 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2007
2008 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2009 r = run_query(hdb, query);
2010 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2011
2012 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2013 r = run_query(hdb, query);
2014 ok(r == ERROR_SUCCESS, "failed to add column\n");
2015
2016 hpkg = package_from_db(hdb);
2017 todo_wine
2018 {
2019 ok(!hpkg, "package should not be created\n");
2020 }
2021
2022 MsiCloseHandle(hdb);
2023 MsiCloseHandle(hpkg);
2024 DeleteFile(msifile);
2025
2026 hdb = create_package_db();
2027 ok (hdb, "failed to create package database\n");
2028
2029 r = create_property_table(hdb);
2030 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2031
2032 r = add_property_entry(hdb, "'prop', 'val'");
2033 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2034
2035 hpkg = package_from_db(hdb);
2036 ok(hpkg, "failed to create package\n");
2037
2038 MsiCloseHandle(hdb);
2039
2040 sz = MAX_PATH;
2041 r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2043 ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2044
2045 hdb = MsiGetActiveDatabase(hpkg);
2046
2047 found = find_prop_in_property(hdb, "prop", "val");
2048 ok(found, "prop should be in the _Property table\n");
2049
2050 r = add_property_entry(hdb, "'dantes', 'mercedes'");
2051 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2052
2053 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2054 r = do_query(hdb, query, &hrec);
2055 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2056
2057 found = find_prop_in_property(hdb, "dantes", "mercedes");
2058 ok(found == FALSE, "dantes should not be in the _Property table\n");
2059
2060 sz = MAX_PATH;
2061 lstrcpy(buffer, "aaa");
2062 r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2064 ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2065
2066 r = MsiSetProperty(hpkg, "dantes", "mercedes");
2067 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2068
2069 found = find_prop_in_property(hdb, "dantes", "mercedes");
2070 ok(found == TRUE, "dantes should be in the _Property table\n");
2071
2072 MsiCloseHandle(hdb);
2073 MsiCloseHandle(hpkg);
2074 DeleteFile(msifile);
2075 }
2076
2077 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2078 {
2079 MSIHANDLE htab = 0;
2080 UINT res;
2081
2082 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2083 if( res == ERROR_SUCCESS )
2084 {
2085 UINT r;
2086
2087 r = MsiViewExecute( htab, hrec );
2088 if( r != ERROR_SUCCESS )
2089 {
2090 res = r;
2091 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2092 }
2093
2094 r = MsiViewClose( htab );
2095 if( r != ERROR_SUCCESS )
2096 res = r;
2097
2098 r = MsiCloseHandle( htab );
2099 if( r != ERROR_SUCCESS )
2100 res = r;
2101 }
2102 return res;
2103 }
2104
2105 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2106 {
2107 return try_query_param( hdb, szQuery, 0 );
2108 }
2109
2110 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2111 {
2112 MSIHANDLE summary;
2113 UINT r;
2114
2115 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2116 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2117
2118 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2120
2121 r = MsiSummaryInfoPersist(summary);
2122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2123
2124 MsiCloseHandle(summary);
2125 }
2126
2127 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2128 {
2129 MSIHANDLE summary;
2130 UINT r;
2131
2132 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2134
2135 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2136 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2137
2138 r = MsiSummaryInfoPersist(summary);
2139 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2140
2141 MsiCloseHandle(summary);
2142 }
2143
2144 static void test_msipackage(void)
2145 {
2146 MSIHANDLE hdb = 0, hpack = 100;
2147 UINT r;
2148 const char *query;
2149 char name[10];
2150
2151 /* NULL szPackagePath */
2152 r = MsiOpenPackage(NULL, &hpack);
2153 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2154
2155 /* empty szPackagePath */
2156 r = MsiOpenPackage("", &hpack);
2157 todo_wine
2158 {
2159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2160 }
2161
2162 if (r == ERROR_SUCCESS)
2163 MsiCloseHandle(hpack);
2164
2165 /* nonexistent szPackagePath */
2166 r = MsiOpenPackage("nonexistent", &hpack);
2167 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2168
2169 /* NULL hProduct */
2170 r = MsiOpenPackage(msifile, NULL);
2171 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2172
2173 name[0]='#';
2174 name[1]=0;
2175 r = MsiOpenPackage(name, &hpack);
2176 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2177
2178 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2180
2181 /* database exists, but is emtpy */
2182 sprintf(name, "#%d", hdb);
2183 r = MsiOpenPackage(name, &hpack);
2184 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2185 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2186
2187 query = "CREATE TABLE `Property` ( "
2188 "`Property` CHAR(72), `Value` CHAR(0) "
2189 "PRIMARY KEY `Property`)";
2190 r = try_query(hdb, query);
2191 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2192
2193 query = "CREATE TABLE `InstallExecuteSequence` ("
2194 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2195 "PRIMARY KEY `Action`)";
2196 r = try_query(hdb, query);
2197 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2198
2199 /* a few key tables exist */
2200 sprintf(name, "#%d", hdb);
2201 r = MsiOpenPackage(name, &hpack);
2202 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2203 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2204
2205 MsiCloseHandle(hdb);
2206 DeleteFile(msifile);
2207
2208 /* start with a clean database to show what constitutes a valid package */
2209 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2210 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2211
2212 sprintf(name, "#%d", hdb);
2213
2214 /* The following summary information props must exist:
2215 * - PID_REVNUMBER
2216 * - PID_PAGECOUNT
2217 */
2218
2219 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2220 r = MsiOpenPackage(name, &hpack);
2221 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2222 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2223
2224 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2225 r = MsiOpenPackage(name, &hpack);
2226 ok(r == ERROR_SUCCESS,
2227 "Expected ERROR_SUCCESS, got %d\n", r);
2228
2229 MsiCloseHandle(hpack);
2230 MsiCloseHandle(hdb);
2231 DeleteFile(msifile);
2232 }
2233
2234 static void test_formatrecord2(void)
2235 {
2236 MSIHANDLE hpkg, hrec ;
2237 char buffer[0x100];
2238 DWORD sz;
2239 UINT r;
2240
2241 hpkg = package_from_db(create_package_db());
2242 ok( hpkg, "failed to create package\n");
2243
2244 r = MsiSetProperty(hpkg, "Manufacturer", " " );
2245 ok( r == ERROR_SUCCESS, "set property failed\n");
2246
2247 hrec = MsiCreateRecord(2);
2248 ok(hrec, "create record failed\n");
2249
2250 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2251 ok( r == ERROR_SUCCESS, "format record failed\n");
2252
2253 buffer[0] = 0;
2254 sz = sizeof buffer;
2255 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2256
2257 r = MsiRecordSetString(hrec, 0, "[foo][1]");
2258 r = MsiRecordSetString(hrec, 1, "hoo");
2259 sz = sizeof buffer;
2260 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2261 ok( sz == 3, "size wrong\n");
2262 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2263 ok( r == ERROR_SUCCESS, "format failed\n");
2264
2265 r = MsiRecordSetString(hrec, 0, "x[~]x");
2266 sz = sizeof buffer;
2267 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2268 ok( sz == 3, "size wrong\n");
2269 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2270 ok( r == ERROR_SUCCESS, "format failed\n");
2271
2272 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2273 r = MsiRecordSetString(hrec, 1, "hoo");
2274 sz = sizeof buffer;
2275 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2276 ok( sz == 3, "size wrong\n");
2277 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2278 ok( r == ERROR_SUCCESS, "format failed\n");
2279
2280 r = MsiRecordSetString(hrec, 0, "[\\[]");
2281 sz = sizeof buffer;
2282 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2283 ok( sz == 1, "size wrong\n");
2284 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2285 ok( r == ERROR_SUCCESS, "format failed\n");
2286
2287 SetEnvironmentVariable("FOO", "BAR");
2288 r = MsiRecordSetString(hrec, 0, "[%FOO]");
2289 sz = sizeof buffer;
2290 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2291 ok( sz == 3, "size wrong\n");
2292 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2293 ok( r == ERROR_SUCCESS, "format failed\n");
2294
2295 r = MsiRecordSetString(hrec, 0, "[[1]]");
2296 r = MsiRecordSetString(hrec, 1, "%FOO");
2297 sz = sizeof buffer;
2298 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2299 ok( sz == 3, "size wrong\n");
2300 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2301 ok( r == ERROR_SUCCESS, "format failed\n");
2302
2303 MsiCloseHandle( hrec );
2304 MsiCloseHandle( hpkg );
2305 DeleteFile(msifile);
2306 }
2307
2308 static void test_states(void)
2309 {
2310 MSIHANDLE hpkg;
2311 UINT r;
2312 MSIHANDLE hdb;
2313 INSTALLSTATE state, action;
2314
2315 static const CHAR msifile2[] = "winetest2.msi";
2316 static const CHAR msifile3[] = "winetest3.msi";
2317 static const CHAR msifile4[] = "winetest4.msi";
2318
2319 hdb = create_package_db();
2320 ok ( hdb, "failed to create package database\n" );
2321
2322 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2323 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2324
2325 r = create_property_table( hdb );
2326 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2327
2328 r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2329 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2330
2331 r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2332 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2333
2334 r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2335 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2336
2337 r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2338 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2339
2340 r = create_install_execute_sequence_table( hdb );
2341 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2342
2343 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2344 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2345
2346 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2347 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2348
2349 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2350 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2351
2352 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2353 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2354
2355 r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2356 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2357
2358 r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2359 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2360
2361 r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2362 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2363
2364 r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2365 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2366
2367 r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2368 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2369
2370 r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2371 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2372
2373 r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2374 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2375
2376 r = create_media_table( hdb );
2377 ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2378
2379 r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2380 ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2381
2382 r = create_feature_table( hdb );
2383 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2384
2385 r = create_component_table( hdb );
2386 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2387
2388 /* msidbFeatureAttributesFavorLocal */
2389 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2390 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2391
2392 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2393 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2394 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2395
2396 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2397 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2398 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2399
2400 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2401 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2402 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2403
2404 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2405 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2406 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2407
2408 /* msidbFeatureAttributesFavorSource */
2409 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2410 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2411
2412 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2413 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2414 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2415
2416 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2417 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2418 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2419
2420 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2421 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2422 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2423
2424 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2425 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2426 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2427
2428 /* msidbFeatureAttributesFavorSource */
2429 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2430 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2431
2432 /* msidbFeatureAttributesFavorLocal */
2433 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2434 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2435
2436 /* disabled */
2437 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2438 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2439
2440 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2441 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2442 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2443
2444 /* no feature parent:msidbComponentAttributesLocalOnly */
2445 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2446 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2447
2448 /* msidbFeatureAttributesFavorLocal:removed */
2449 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2450 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2451
2452 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2453 r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2454 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2455
2456 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2457 r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2458 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2459
2460 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2461 r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2462 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2463
2464 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2465 r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2466 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2467
2468 /* msidbFeatureAttributesFavorSource:removed */
2469 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2470 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2471
2472 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2473 r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2474 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2475
2476 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2477 r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2478 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2479
2480 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2481 r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2482 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2483
2484 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2485 r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2486 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2487
2488 /* msidbFeatureAttributesFavorLocal */
2489 r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2490 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2491
2492 r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2493 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2494
2495 /* msidbFeatureAttributesFavorSource */
2496 r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2497 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2498
2499 r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2500 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2501
2502 /* msidbFeatureAttributesFavorAdvertise */
2503 r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2504 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2505
2506 r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2507 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2508
2509 r = create_feature_components_table( hdb );
2510 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2511
2512 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2513 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2514
2515 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2516 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2517
2518 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2519 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2520
2521 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2522 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2523
2524 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2525 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2526
2527 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2528 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2529
2530 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2531 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2532
2533 r = add_feature_components_entry( hdb, "'two', 'iota'" );
2534 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2535
2536 r = add_feature_components_entry( hdb, "'three', 'eta'" );
2537 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2538
2539 r = add_feature_components_entry( hdb, "'four', 'eta'" );
2540 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2541
2542 r = add_feature_components_entry( hdb, "'five', 'eta'" );
2543 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2544
2545 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2546 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2547
2548 r = add_feature_components_entry( hdb, "'six', 'mu'" );
2549 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2550
2551 r = add_feature_components_entry( hdb, "'six', 'nu'" );
2552 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2553
2554 r = add_feature_components_entry( hdb, "'six', 'xi'" );
2555 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2556
2557 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2558 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2559
2560 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2561 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2562
2563 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2564 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2565
2566 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2567 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2568
2569 r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2570 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2571
2572 r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2573 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2574
2575 r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2576 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2577
2578 r = create_file_table( hdb );
2579 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2580
2581 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2582 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2583
2584 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2585 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2586
2587 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2588 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2589
2590 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2591 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2592
2593 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2594 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2595
2596 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2597 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2598
2599 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2600 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2601
2602 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2603 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2604
2605 /* compressed file */
2606 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2607 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2608
2609 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2610 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2611
2612 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2613 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2614
2615 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2616 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2617
2618 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2619 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2620
2621 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2622 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2623
2624 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2625 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2626
2627 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2628 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2629
2630 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2631 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2632
2633 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2634 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2635
2636 r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2637 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2638
2639 r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2640 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2641
2642 r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2643 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2644
2645 MsiDatabaseCommit(hdb);
2646
2647 /* these properties must not be in the saved msi file */
2648 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2649 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2650
2651 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2652 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2653
2654 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2655 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2656
2657 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2658 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2659
2660 r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2661 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2662
2663 hpkg = package_from_db( hdb );
2664 ok( hpkg, "failed to create package\n");
2665
2666 MsiCloseHandle(hdb);
2667
2668 CopyFileA(msifile, msifile2, FALSE);
2669 CopyFileA(msifile, msifile3, FALSE);
2670 CopyFileA(msifile, msifile4, FALSE);
2671
2672 state = 0xdeadbee;
2673 action = 0xdeadbee;
2674 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2675 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2676 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2677 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2678
2679 state = 0xdeadbee;
2680 action = 0xdeadbee;
2681 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2682 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2683 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2684 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2685
2686 state = 0xdeadbee;
2687 action = 0xdeadbee;
2688 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2689 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2690 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2691 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2692
2693 state = 0xdeadbee;
2694 action = 0xdeadbee;
2695 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2696 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2697 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2698 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2699
2700 state = 0xdeadbee;
2701 action = 0xdeadbee;
2702 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2703 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2704 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2705 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2706
2707 state = 0xdeadbee;
2708 action = 0xdeadbee;
2709 r = MsiGetFeatureState(hpkg, "six", &state, &action);
2710 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2711 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2712 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2713
2714 state = 0xdeadbee;
2715 action = 0xdeadbee;
2716 r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2717 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2718 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2719 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2720
2721 state = 0xdeadbee;
2722 action = 0xdeadbee;
2723 r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2724 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2725 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2726 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2727
2728 state = 0xdeadbee;
2729 action = 0xdeadbee;
2730 r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2731 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2732 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2733 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2734
2735 state = 0xdeadbee;
2736 action = 0xdeadbee;
2737 r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2738 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2739 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2740 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2741
2742 state = 0xdeadbee;
2743 action = 0xdeadbee;
2744 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2745 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2746 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2747 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2748
2749 state = 0xdeadbee;
2750 action = 0xdeadbee;
2751 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2752 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2753 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2754 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2755
2756 state = 0xdeadbee;
2757 action = 0xdeadbee;
2758 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2759 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2760 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2761 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2762
2763 state = 0xdeadbee;
2764 action = 0xdeadbee;
2765 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2766 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2767 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2768 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2769
2770 state = 0xdeadbee;
2771 action = 0xdeadbee;
2772 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2773 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2774 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2775 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2776
2777 state = 0xdeadbee;
2778 action = 0xdeadbee;
2779 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2780 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2781 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2782 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2783
2784 state = 0xdeadbee;
2785 action = 0xdeadbee;
2786 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2787 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2788 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2789 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2790
2791 state = 0xdeadbee;
2792 action = 0xdeadbee;
2793 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2794 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2795 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2796 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2797
2798 state = 0xdeadbee;
2799 action = 0xdeadbee;
2800 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2801 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2802 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2803 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2804
2805 state = 0xdeadbee;
2806 action = 0xdeadbee;
2807 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2808 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2809 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2810 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2811
2812 state = 0xdeadbee;
2813 action = 0xdeadbee;
2814 r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2815 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2816 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2817 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2818
2819 state = 0xdeadbee;
2820 action = 0xdeadbee;
2821 r = MsiGetComponentState(hpkg, "mu", &state, &action);
2822 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2823 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2824 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2825
2826 state = 0xdeadbee;
2827 action = 0xdeadbee;
2828 r = MsiGetComponentState(hpkg, "nu", &state, &action);
2829 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2830 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2831 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2832
2833 state = 0xdeadbee;
2834 action = 0xdeadbee;
2835 r = MsiGetComponentState(hpkg, "xi", &state, &action);
2836 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2837 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2838 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2839
2840 state = 0xdeadbee;
2841 action = 0xdeadbee;
2842 r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2843 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2844 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2845 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2846
2847 state = 0xdeadbee;
2848 action = 0xdeadbee;
2849 r = MsiGetComponentState(hpkg, "pi", &state, &action);
2850 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2851 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2852 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2853
2854 state = 0xdeadbee;
2855 action = 0xdeadbee;
2856 r = MsiGetComponentState(hpkg, "rho", &state, &action);
2857 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2858 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2859 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2860
2861 state = 0xdeadbee;
2862 action = 0xdeadbee;
2863 r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2864 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2865 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2866 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2867
2868 state = 0xdeadbee;
2869 action = 0xdeadbee;
2870 r = MsiGetComponentState(hpkg, "tau", &state, &action);
2871 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2872 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2873 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2874
2875 state = 0xdeadbee;
2876 action = 0xdeadbee;
2877 r = MsiGetComponentState(hpkg, "phi", &state, &action);
2878 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2879 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2880 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2881
2882 state = 0xdeadbee;
2883 action = 0xdeadbee;
2884 r = MsiGetComponentState(hpkg, "chi", &state, &action);
2885 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2886 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2887 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2888
2889 r = MsiDoAction( hpkg, "CostInitialize");
2890 ok( r == ERROR_SUCCESS, "cost init failed\n");
2891
2892 state = 0xdeadbee;
2893 action = 0xdeadbee;
2894 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2895 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2896 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2897 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2898
2899 state = 0xdeadbee;
2900 action = 0xdeadbee;
2901 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2902 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2903 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2904 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2905
2906 state = 0xdeadbee;
2907 action = 0xdeadbee;
2908 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2909 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2910 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2911 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2912
2913 state = 0xdeadbee;
2914 action = 0xdeadbee;
2915 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2916 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2917 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2918 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2919
2920 state = 0xdeadbee;
2921 action = 0xdeadbee;
2922 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2923 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2924 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2925 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2926
2927 state = 0xdeadbee;
2928 action = 0xdeadbee;
2929 r = MsiGetFeatureState(hpkg, "six", &state, &action);
2930 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2931 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2932 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2933
2934 state = 0xdeadbee;
2935 action = 0xdeadbee;
2936 r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2937 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2938 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2939 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2940
2941 state = 0xdeadbee;
2942 action = 0xdeadbee;
2943 r = MsiGetFeatureState(hpkg, "eight", &state, &action);
2944 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2945 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2946 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2947
2948 state = 0xdeadbee;
2949 action = 0xdeadbee;
2950 r = MsiGetFeatureState(hpkg, "nine", &state, &action);
2951 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2952 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2953 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2954
2955 state = 0xdeadbee;
2956 action = 0xdeadbee;
2957 r = MsiGetFeatureState(hpkg, "ten", &state, &action);
2958 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2959 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2960 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2961
2962 state = 0xdeadbee;
2963 action = 0xdeadbee;
2964 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2965 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2966 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2967 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2968
2969 state = 0xdeadbee;
2970 action = 0xdeadbee;
2971 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2972 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2973 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2974 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2975
2976 state = 0xdeadbee;
2977 action = 0xdeadbee;
2978 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2979 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2980 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2981 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2982
2983 state = 0xdeadbee;
2984 action = 0xdeadbee;
2985 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2986 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2987 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2988 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2989
2990 state = 0xdeadbee;
2991 action = 0xdeadbee;
2992 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2993 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2994 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2995 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2996
2997 state = 0xdeadbee;
2998 action = 0xdeadbee;
2999 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3000 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3001 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3002 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3003
3004 state = 0xdeadbee;
3005 action = 0xdeadbee;
3006 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3007 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3008 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3009 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3010
3011 state = 0xdeadbee;
3012 action = 0xdeadbee;
3013 r = MsiGetComponentState(hpkg, "iota", &state, &action);
3014 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3015 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3016 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3017
3018 state = 0xdeadbee;
3019 action = 0xdeadbee;
3020 r = MsiGetComponentState(hpkg, "eta", &state, &action);
3021 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3022 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3023 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3024
3025 state = 0xdeadbee;
3026 action = 0xdeadbee;
3027 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3028 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3029 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3030 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3031
3032 state = 0xdeadbee;
3033 action = 0xdeadbee;
3034 r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3035 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3036 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3037 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3038
3039 state = 0xdeadbee;
3040 action = 0xdeadbee;
3041 r = MsiGetComponentState(hpkg, "mu", &state, &action);
3042 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3043 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3044 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3045
3046 state = 0xdeadbee;
3047 action = 0xdeadbee;
3048 r = MsiGetComponentState(hpkg, "nu", &state, &action);
3049 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3050 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3051 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3052
3053 state = 0xdeadbee;
3054 action = 0xdeadbee;
3055 r = MsiGetComponentState(hpkg, "xi", &state, &action);
3056 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3057 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3058 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3059
3060 state = 0xdeadbee;
3061 action = 0xdeadbee;
3062 r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3063 ok